[测评系统]--测评系统核心代码库
wzp
2024-12-30 6620dc7b245127616cb580700eb026da03e96de5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.ots.project.tool;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class AppUtil implements ApplicationContextAware {
    private static ApplicationContext applicationContext;
    public static <T> T getObject(String id, Class T) {
        T bean = (T) applicationContext.getBean(id, T);
        return bean;
    }
    @Override
    public void setApplicationContext(ApplicationContext arg0) throws BeansException {
        applicationContext = arg0;
    }
}