feat: 抽取通用的资源服务器配置
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.central.common.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.central.common.constant.SecurityConstants;
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.feign.UserService;
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.central.common.utils;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* spring获取bean工具类
|
||||
*
|
||||
* @author 作者 owen E-mail: 624191343@qq.com
|
||||
*/
|
||||
@Order(0)
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext = null;
|
||||
|
||||
public static <T> T getBean(Class<T> cla) {
|
||||
return applicationContext.getBean(cla);
|
||||
}
|
||||
|
||||
public static <T> T getBean(String name, Class<T> cal) {
|
||||
return applicationContext.getBean(name, cal);
|
||||
}
|
||||
|
||||
public static String getProperty(String key) {
|
||||
return applicationContext.getBean(Environment.class).getProperty(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user