liding
16 小时以前 c7ce2c2342f427bbad0263ab9e35585f6b98ee93
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);
    }
}