maven
10 天以前 1f1ef0f62c4953e3ff9c610cda8f3c4f8a45c025
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);
    }
}