sub/pub模式在软件设计中是非常常见的,他可以很优雅的帮我们解耦合,很多优秀的软件中都能看到他的影子,不如redis,zk,rxjava等,spring的内部也有很多的应用,今天我们就说一下事件的监听。
首先我们要知道事件的种类是多种多样的,我们的事件监听器(EventListener)关注什么样的事件呢?根据这个思路我们看下本次课程我们定义的
package com.shuqi.listener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import java.util.stream.Stream;
@Slf4j
public class TestListener implements ApplicationListener<ContextRefreshedEvent> {
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
Stream.of(applicationContext.getBeanNamesForType(Object.class)).forEach(log::info);
}
}
实例中的事件监听器关注的是ContextRefreshedEvent的事件,也就是说当容器refresh结束的时候会发出这个事件,我们的监听器就能监听到,所做的操作就是打印容器中的Bean的名称。
那么我们事件是有了,我们下一步就不要将这个事件监听器让Spring boot知道,所以就是一个注册。
package com.shuqi;
import com.shuqi.listener.TestListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.text.SimpleDateFormat;
import java.util.Date;
@SpringBootApplication
public class ApplicationMain {
public static void main(String[] args) {
SpringApplication springApplication=new SpringApplication(ApplicationMain.class);
springApplication.addListeners(new TestListener());
springApplication.run(args);
System.out.println(new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]").format(new Date()) + " server started!");
}
}
这样我们一个事件监听器就完成了。
启动看看效果
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=63733:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/lib/tools.jar:/Users/olifer/github/spring-boot-test/spring-boot-event-listener-start/target/classes:/Users/olifer/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.5.RELEASE/spring-boot-starter-1.3.5.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/boot/spring-boot/1.3.5.RELEASE/spring-boot-1.3.5.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/spring-context/4.2.6.RELEASE/spring-context-4.2.6.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.5.RELEASE/spring-boot-autoconfigure-1.3.5.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.5.RELEASE/spring-boot-starter-logging-1.3.5.RELEASE.jar:/Users/olifer/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar:/Users/olifer/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar:/Users/olifer/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar:/Users/olifer/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar:/Users/olifer/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar:/Users/olifer/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar:/Users/olifer/.m2/repository/org/springframework/spring-core/4.2.6.RELEASE/spring-core-4.2.6.RELEASE.jar:/Users/olifer/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar:/Users/olifer/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.5.RELEASE/spring-boot-starter-web-1.3.5.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.3.5.RELEASE/spring-boot-starter-tomcat-1.3.5.RELEASE.jar:/Users/olifer/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.33/tomcat-embed-core-8.0.33.jar:/Users/olifer/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.33/tomcat-embed-el-8.0.33.jar:/Users/olifer/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.33/tomcat-embed-logging-juli-8.0.33.jar:/Users/olifer/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.33/tomcat-embed-websocket-8.0.33.jar:/Users/olifer/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.5.RELEASE/spring-boot-starter-validation-1.3.5.RELEASE.jar:/Users/olifer/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar:/Users/olifer/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/Users/olifer/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar:/Users/olifer/.m2/repository/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar:/Users/olifer/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.6/jackson-databind-2.6.6.jar:/Users/olifer/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.6/jackson-annotations-2.6.6.jar:/Users/olifer/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.6/jackson-core-2.6.6.jar:/Users/olifer/.m2/repository/org/springframework/spring-web/4.2.6.RELEASE/spring-web-4.2.6.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/spring-aop/4.2.6.RELEASE/spring-aop-4.2.6.RELEASE.jar:/Users/olifer/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/olifer/.m2/repository/org/springframework/spring-beans/4.2.6.RELEASE/spring-beans-4.2.6.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/spring-webmvc/4.2.6.RELEASE/spring-webmvc-4.2.6.RELEASE.jar:/Users/olifer/.m2/repository/org/springframework/spring-expression/4.2.6.RELEASE/spring-expression-4.2.6.RELEASE.jar:/Users/olifer/.m2/repository/org/projectlombok/lombok/1.14.8/lombok-1.14.8.jar com.shuqi.ApplicationMain
objc[3632]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.5.RELEASE)
2018-03-25 15:11:07.306 INFO 3632 --- [ main] com.shuqi.ApplicationMain : Starting ApplicationMain on oliferdeMacBook-Pro.local with PID 3632 (/Users/olifer/github/spring-boot-test/spring-boot-event-listener-start/target/classes started by olifer in /Users/olifer/github/spring-boot-test)
2018-03-25 15:11:07.321 INFO 3632 --- [ main] com.shuqi.ApplicationMain : No active profile set, falling back to default profiles: default
2018-03-25 15:11:07.482 INFO 3632 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1cab0bfb: startup date [Sun Mar 25 15:11:07 CST 2018]; root of context hierarchy
2018-03-25 15:11:09.661 INFO 3632 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-03-25 15:11:09.677 INFO 3632 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2018-03-25 15:11:09.679 INFO 3632 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.33
2018-03-25 15:11:09.811 INFO 3632 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-03-25 15:11:09.812 INFO 3632 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2337 ms
2018-03-25 15:11:10.158 INFO 3632 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-03-25 15:11:10.162 INFO 3632 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-03-25 15:11:10.163 INFO 3632 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-03-25 15:11:10.163 INFO 3632 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-03-25 15:11:10.163 INFO 3632 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-03-25 15:11:10.433 INFO 3632 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1cab0bfb: startup date [Sun Mar 25 15:11:07 CST 2018]; root of context hierarchy
2018-03-25 15:11:10.519 INFO 3632 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-03-25 15:11:10.520 INFO 3632 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-03-25 15:11:10.550 INFO 3632 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-25 15:11:10.550 INFO 3632 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-25 15:11:10.593 INFO 3632 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-25 15:11:10.714 INFO 3632 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.annotation.internalConfigurationAnnotationProcessor
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.annotation.internalAutowiredAnnotationProcessor
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.annotation.internalRequiredAnnotationProcessor
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.annotation.internalCommonAnnotationProcessor
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.event.internalEventListenerProcessor
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.event.internalEventListenerFactory
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : applicationMain
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor
2018-03-25 15:11:10.734 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.AutoConfigurationPackages
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.condition.BeanTypeRegistry
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : propertySourcesPlaceholderConfigurer
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$TomcatWebSocketConfiguration
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : websocketContainerCustomizer
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : tomcatEmbeddedServletContainerFactory
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : embeddedServletContainerCustomizerBeanPostProcessor
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : dispatcherServlet
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : dispatcherServletRegistration
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : spring.mvc.CONFIGURATION_PROPERTIES
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store
2018-03-25 15:11:10.735 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : error
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : beanNameViewResolver
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : errorAttributes
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : basicErrorController
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : errorPageCustomizer
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : preserveErrorControllerTargetClassPostProcessor
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : requestMappingHandlerAdapter
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : requestMappingHandlerMapping
2018-03-25 15:11:10.736 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcContentNegotiationManager
2018-03-25 15:11:10.737 INFO 3632 --- [ main] com.shuqi.listener.TestListener : viewControllerHandlerMapping
2018-03-25 15:11:10.737 INFO 3632 --- [ main] com.shuqi.listener.TestListener : beanNameHandlerMapping
2018-03-25 15:11:10.737 INFO 3632 --- [ main] com.shuqi.listener.TestListener : resourceHandlerMapping
2018-03-25 15:11:10.737 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcResourceUrlProvider
2018-03-25 15:11:10.737 INFO 3632 --- [ main] com.shuqi.listener.TestListener : defaultServletHandlerMapping
2018-03-25 15:11:10.737 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcConversionService
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcValidator
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcPathMatcher
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcUrlPathHelper
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcUriComponentsContributor
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : httpRequestHandlerAdapter
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : simpleControllerHandlerAdapter
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : handlerExceptionResolver
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mvcViewResolver
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter$FaviconConfiguration
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : faviconHandlerMapping
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : faviconRequestHandler
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : defaultViewResolver
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : requestContextFilter
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : viewResolver
2018-03-25 15:11:10.738 INFO 3632 --- [ main] com.shuqi.listener.TestListener : spring.resources.CONFIGURATION_PROPERTIES
2018-03-25 15:11:10.739 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
2018-03-25 15:11:10.739 INFO 3632 --- [ main] com.shuqi.listener.TestListener : hiddenHttpMethodFilter
2018-03-25 15:11:10.739 INFO 3632 --- [ main] com.shuqi.listener.TestListener : httpPutFormContentFilter
2018-03-25 15:11:10.739 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration
2018-03-25 15:11:10.739 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mbeanExporter
2018-03-25 15:11:10.739 INFO 3632 --- [ main] com.shuqi.listener.TestListener : objectNamingStrategy
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mbeanServer
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : jacksonObjectMapperBuilder
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : spring.jackson.CONFIGURATION_PROPERTIES
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : jacksonObjectMapper
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : stringHttpMessageConverter
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : spring.http.encoding.CONFIGURATION_PROPERTIES
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : mappingJackson2HttpMessageConverter
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : messageConverters
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : characterEncodingFilter
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : multipartConfigElement
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : multipartResolver
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : multipart.CONFIGURATION_PROPERTIES
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
2018-03-25 15:11:10.740 INFO 3632 --- [ main] com.shuqi.listener.TestListener : serverProperties
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : duplicateServerPropertiesDetector
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : autoConfigurationReport
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : applicationEventMulticaster
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : springApplicationArguments
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : springBootLoggingSystem
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : environment
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : systemProperties
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : systemEnvironment
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : messageSource
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : servletContext
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : contextParameters
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : contextAttributes
2018-03-25 15:11:10.741 INFO 3632 --- [ main] com.shuqi.listener.TestListener : lifecycleProcessor
2018-03-25 15:11:10.827 INFO 3632 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-03-25 15:11:10.832 INFO 3632 --- [ main] com.shuqi.ApplicationMain : Started ApplicationMain in 4.23 seconds (JVM running for 4.84)
[2018-03-25 15:11:10] server started!
看到输出的日志的下半部分都是Bean的名称,我们的监听器生效了,抓紧时间玩起来吧。
下节将的内容是:SpringBoot基础教程(十三)——与配置文件属性注入的结合
网友评论