优化代码

This commit is contained in:
smallchill 2018-12-27 09:17:17 +08:00
parent 50ecac95b2
commit d40e743be9

View File

@ -15,6 +15,7 @@
*/ */
package org.springblade.core.tool.utils; package org.springblade.core.tool.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
@ -23,6 +24,7 @@ import org.springframework.context.ApplicationEvent;
/** /**
* spring 工具类 * spring 工具类
*/ */
@Slf4j
public class SpringUtil implements ApplicationContextAware { public class SpringUtil implements ApplicationContextAware {
private static ApplicationContext context; private static ApplicationContext context;
@ -61,7 +63,11 @@ public class SpringUtil implements ApplicationContextAware {
public static void publishEvent(ApplicationEvent event) { public static void publishEvent(ApplicationEvent event) {
if (context == null) return; if (context == null) return;
context.publishEvent(event); try {
context.publishEvent(event);
} catch (Exception ex) {
log.error(ex.getMessage());
}
} }
} }