| | |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.context.ApplicationContext; |
| | | |
| | | import java.util.Locale; |
| | | |
| | | /** |
| | | * Created by wuxw on 2017/4/25. |
| | | */ |
| | |
| | | ApplicationContextFactory.applicationContext = applicationContext; |
| | | } |
| | | |
| | | public static Object getBean(Class className){ |
| | | public static Object getBean(Class<?> className){ |
| | | return applicationContext.getBean(className); |
| | | } |
| | | |
| | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取应用名称 |
| | | * @return |
| | | */ |
| | | public static String getApplicationName(){ |
| | | return applicationContext.getEnvironment().getProperty("spring.application.name"); |
| | | } |
| | | |
| | | |
| | | // 国际化使用 |
| | | public static String getMessage(String key) { |
| | | return applicationContext.getMessage(key, null, Locale.getDefault()); |
| | | } |
| | | |
| | | |
| | | /// 获取当前环境 |
| | | public static String getActiveProfile() { |
| | | return applicationContext.getEnvironment().getActiveProfiles()[0]; |
| | | } |
| | | |
| | | |
| | | } |