mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	bean工具类替换为hutool的
This commit is contained in:
		| @ -1,8 +1,8 @@ | |||||||
| package cn.iocoder.dashboard.framework.tracer.core.util; | package cn.iocoder.dashboard.framework.tracer.core.util; | ||||||
|  |  | ||||||
| import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||||
|  | import cn.hutool.extra.spring.SpringUtil; | ||||||
| import cn.iocoder.dashboard.framework.tracer.core.ITrace; | import cn.iocoder.dashboard.framework.tracer.core.ITrace; | ||||||
| import cn.iocoder.dashboard.util.sping.SpringBeanUtil; |  | ||||||
| import org.apache.skywalking.apm.toolkit.trace.TraceContext; | import org.apache.skywalking.apm.toolkit.trace.TraceContext; | ||||||
|  |  | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| @ -61,7 +61,7 @@ public class TracerUtils { | |||||||
|      * @return ITrace |      * @return ITrace | ||||||
|      */ |      */ | ||||||
|     private static ITrace getTracer() { |     private static ITrace getTracer() { | ||||||
|         return SpringBeanUtil.getBean(ITrace.class); |         return SpringUtil.getBean(ITrace.class); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -1,83 +0,0 @@ | |||||||
| package cn.iocoder.dashboard.util.sping; |  | ||||||
|  |  | ||||||
| import org.springframework.beans.BeansException; |  | ||||||
|  |  | ||||||
| import org.springframework.beans.factory.NoSuchBeanDefinitionException; |  | ||||||
|  |  | ||||||
| import org.springframework.context.ApplicationContext; |  | ||||||
|  |  | ||||||
| import org.springframework.context.ApplicationContextAware; |  | ||||||
|  |  | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @Component |  | ||||||
| public class SpringBeanUtil implements ApplicationContextAware { |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Spring context |  | ||||||
|      */ |  | ||||||
|     private static ApplicationContext applicationContext = null; |  | ||||||
|  |  | ||||||
|     public void setApplicationContext(ApplicationContext context) throws BeansException { |  | ||||||
|         if (applicationContext == null) { |  | ||||||
|             applicationContext = context; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static ApplicationContext getApplicationContext() { |  | ||||||
|         return applicationContext; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void setAppCtx(ApplicationContext webAppCtx) { |  | ||||||
|         if (webAppCtx != null) { |  | ||||||
|             applicationContext = webAppCtx; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 拿到ApplicationContext对象实例后就可以手动获取Bean的注入实例对象 |  | ||||||
|      */ |  | ||||||
|     public static <T> T getBean(Class<T> clazz) { |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext().getBean(clazz); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static <T> T getBean(String name, Class<T> clazz) throws ClassNotFoundException { |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext() .getBean(name, clazz); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static final Object getBean(String beanName) { |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext() .getBean(beanName); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static final Object getBean(String beanName, String className) throws ClassNotFoundException { |  | ||||||
|         Class<?> clz = Class.forName(className); |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext() .getBean(beanName, clz.getClass()); |  | ||||||
|  |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static boolean containsBean(String name) { |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext() .containsBean(name); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext() .isSingleton(name); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static Class<?> getType(String name) throws NoSuchBeanDefinitionException { |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext() .getType(name); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { |  | ||||||
|         return getApplicationContext() == null ? null : getApplicationContext() .getAliases(name); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } |  | ||||||
		Reference in New Issue
	
	Block a user
	 dark
					dark