maven
22 小时以前 d7441859ebc52c9969e20a499fa39efe66a697e3
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);
    }
}