yaowanxin
4 天以前 790a5824c6e8529d0c78eb89fd5e7f654a9d9131
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.ruoyi.inspectiontask.service.impl;
 
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
 
@Component
public class SpringContextHolder implements ApplicationContextAware {
    private static ApplicationContext applicationContext;
 
    @Override
    public void setApplicationContext(ApplicationContext context) {
        applicationContext = context;
    }
 
    public static <T> T getBean(Class<T> clazz) {
        return applicationContext.getBean(clazz);
    }
}