From a088987e7ab7005db1bb1da61dfc0cf420e02d78 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 13 十一月 2024 17:11:28 +0800 Subject: [PATCH] 1 --- src/main/java/com/moon/server/helper/SpringContextHelper.java | 47 +---------------------------------------------- 1 files changed, 1 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/moon/server/helper/SpringContextHelper.java b/src/main/java/com/moon/server/helper/SpringContextHelper.java index c988023..783ae6e 100644 --- a/src/main/java/com/moon/server/helper/SpringContextHelper.java +++ b/src/main/java/com/moon/server/helper/SpringContextHelper.java @@ -5,81 +5,36 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; -/** - * Spring涓婁笅鏂囧府鍔╃被 - * @author WWW - */ @Component +@SuppressWarnings("ALL") public class SpringContextHelper implements ApplicationContextAware { private static ApplicationContext context = null; - /** - * 璁剧疆搴旂敤绋嬪簭涓婁笅鏂� - * - * @param applicationContext - * @throws BeansException - */ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { context = applicationContext; } - /** - * 鏍规嵁鍚嶇О鑾峰彇Bean - * - * @param name 绫诲悕绉� - * @return - */ public static <T> T getBean(String name) { return (T) context.getBean(name); } - /** - * 鏍规嵁绫诲瀷鑾峰彇Bean - * - * @param clazz 绫� - * @param <T> 娉涘瀷 - * @return - */ public static <T> T getBean(Class<T> clazz) { return context.getBean(clazz); } - /** - * 鍒ゆ柇鏄惁鍖呭惈瀵瑰簲鍚嶇О鐨凚ean瀵硅薄 - * - * @param name Bean鍚嶇О - * @return 鍖呭惈锛氳繑鍥瀟rue锛屽惁鍒欒繑鍥瀎alse銆� - */ public static boolean containsBean(String name) { return context.containsBean(name); } - /** - * 鑾峰彇瀵瑰簲Bean鍚嶇О鐨勭被鍨� - * - * @param name Bean鍚嶇О - * @return 杩斿洖瀵瑰簲鐨凚ean绫诲瀷 - */ public static Class<?> getType(String name) { return context.getType(name); } - /** - * 鑾峰彇涓婁笅鏂囧璞★紝鍙繘琛屽悇绉峉pring鐨勪笂涓嬫枃鎿嶄綔 - * - * @return Spring涓婁笅鏂囧璞� - */ public static ApplicationContext getContext() { return context; } - - /** - * 鑾峰彇褰撳墠鐜 - * - * @return Profile - */ public static String getActiveProfile() { return context.getEnvironment().getActiveProfiles()[0]; } -- Gitblit v1.9.3