0 课程地址
https://coding.imooc.com/lesson/380.html#mid=28270
1 主要内容
1.1 主要内容
springboot应用启动的三种方式
2 个人收获
2.1 不同的启动方式
通过api调用应用行为方式启动
//第二种方式启动 SpringApplication springApplication = new SpringApplication(SpringBootStudyApplication.class); //关掉打印logo相关日志 springApplication.setBannerMode(Banner.Mode.OFF); //非wub启动,控制台启动后会关闭,不会一直保持开启状态 springApplication.setWebApplicationType(WebApplicationType.NONE); springApplication.run(args);
spingapplicationbuilder 链式调用
//第三种方式启动 链式调用 new SpringApplicationBuilder(SpringBootStudyApplication.class) .bannerMode(Banner.Mode.OFF) .web(WebApplicationType.NONE).run(args);
2.2 启动方式的一些配置
//关掉打印logo相关日志 springApplication.setBannerMode(Banner.Mode.OFF); //非wub启动,控制台启动后会关闭,不会一直保持开启状态,此外还可以通过WebApplicationType的其他变量转换不同的启动方式 springApplication.setWebApplicationType(WebApplicationType.NONE);
3 课程内容
3.1 第一种启动方式:
顶类:
package com.imooc.springboot.application; import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; /** * SpringBootApplication * * @author 魏豆豆 * @date 2021/1/13 */ @SpringBootApplication public class SpringBootStudyApplication { public static void main(String [] args){ //第一种方式启动 SpringApplication.run(SpringBootStudyApplication.class,args); //第二种方式启动 /* SpringApplication springApplication = new SpringApplication(SpringBootStudyApplication.class); //关掉打印logo相关日志 springApplication.setBannerMode(Banner.Mode.OFF); //非wub启动,控制台启动后会关闭,不会一直保持开启状态 springApplication.setWebApplicationType(WebApplicationType.NONE); springApplication.run(args); //第三种方式启动 链式调用 new SpringApplicationBuilder(SpringBootStudyApplication.class) .bannerMode(Banner.Mode.OFF) .web(WebApplicationType.NONE).run(args);*/ } }
打印日志:
D:\java\jdk\jdk8\jdk\bin\java.exe "-javaagent:D:\java\devolopKit\idea\anZh\IntelliJ IDEA Community Edition 2018.1.4\lib\idea_rt.jar=58977:D:\java\devolopKit\idea\anZh\IntelliJ IDEA Community Edition 2018.1.4\bin" -Dfile.encoding=UTF-8 -classpath D:\java\jdk\jdk8\jdk\jre\lib\charsets.jar;D:\java\jdk\jdk8\jdk\jre\lib\deploy.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\access-bridge-64.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\cldrdata.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\dnsns.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\jaccess.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\jfxrt.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\localedata.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\nashorn.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunec.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunjce_provider.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunmscapi.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunpkcs11.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\zipfs.jar;D:\java\jdk\jdk8\jdk\jre\lib\javaws.jar;D:\java\jdk\jdk8\jdk\jre\lib\jce.jar;D:\java\jdk\jdk8\jdk\jre\lib\jfr.jar;D:\java\jdk\jdk8\jdk\jre\lib\jfxswt.jar;D:\java\jdk\jdk8\jdk\jre\lib\jsse.jar;D:\java\jdk\jdk8\jdk\jre\lib\management-agent.jar;D:\java\jdk\jdk8\jdk\jre\lib\plugin.jar;D:\java\jdk\jdk8\jdk\jre\lib\resources.jar;D:\java\jdk\jdk8\jdk\jre\lib\rt.jar;F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study\target\classes;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.1.4.RELEASE\spring-boot-starter-web-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter\2.1.4.RELEASE\spring-boot-starter-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot\2.1.4.RELEASE\spring-boot-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.1.4.RELEASE\spring-boot-autoconfigure-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.1.4.RELEASE\spring-boot-starter-logging-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\weijingli\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\weijingli\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.11.2\log4j-to-slf4j-2.11.2.jar;C:\Users\weijingli\.m2\repository\org\apache\logging\log4j\log4j-api\2.11.2\log4j-api-2.11.2.jar;C:\Users\weijingli\.m2\repository\org\slf4j\jul-to-slf4j\1.7.26\jul-to-slf4j-1.7.26.jar;C:\Users\weijingli\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\weijingli\.m2\repository\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.1.4.RELEASE\spring-boot-starter-json-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.8\jackson-databind-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.8\jackson-core-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.8\jackson-datatype-jdk8-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.8\jackson-datatype-jsr310-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.8\jackson-module-parameter-names-2.9.8.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.1.4.RELEASE\spring-boot-starter-tomcat-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.17\tomcat-embed-core-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.17\tomcat-embed-el-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.17\tomcat-embed-websocket-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.16.Final\hibernate-validator-6.0.16.Final.jar;C:\Users\weijingli\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\weijingli\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\classmate\1.4.0\classmate-1.4.0.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-web\5.1.6.RELEASE\spring-web-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-beans\5.1.6.RELEASE\spring-beans-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-webmvc\5.1.6.RELEASE\spring-webmvc-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-aop\5.1.6.RELEASE\spring-aop-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-context\5.1.6.RELEASE\spring-context-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-expression\5.1.6.RELEASE\spring-expression-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\projectlombok\lombok\1.18.6\lombok-1.18.6.jar;C:\Users\weijingli\.m2\repository\org\slf4j\slf4j-api\1.7.26\slf4j-api-1.7.26.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-core\5.1.6.RELEASE\spring-core-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-jcl\5.1.6.RELEASE\spring-jcl-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\com\alibaba\fastjson\1.2.31\fastjson-1.2.31.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-configuration-processor\2.1.4.RELEASE\spring-boot-configuration-processor-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-actuator\2.1.4.RELEASE\spring-boot-starter-actuator-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-actuator-autoconfigure\2.1.4.RELEASE\spring-boot-actuator-autoconfigure-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-actuator\2.1.4.RELEASE\spring-boot-actuator-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\io\micrometer\micrometer-core\1.1.4\micrometer-core-1.1.4.jar;C:\Users\weijingli\.m2\repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;C:\Users\weijingli\.m2\repository\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar com.imooc.springboot.application.SpringBootStudyApplication . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.4.RELEASE) 2021-01-14 07:14:39.891 INFO 14528 --- [ main] c.i.s.a.SpringBootStudyApplication : Starting SpringBootStudyApplication on DESKTOP-A08HONB with PID 14528 (F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study\target\classes started by weijingli in F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study) 2021-01-14 07:14:39.900 INFO 14528 --- [ main] c.i.s.a.SpringBootStudyApplication : No active profile set, falling back to default profiles: default 2021-01-14 07:14:43.183 ERROR 14528 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.1.32] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14] 2021-01-14 07:14:44.685 ERROR 14528 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.1.32] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14] 2021-01-14 07:14:44.897 INFO 14528 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2021-01-14 07:14:44.924 ERROR 14528 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.1.32] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14] 2021-01-14 07:14:44.943 INFO 14528 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-01-14 07:14:44.943 INFO 14528 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17] 2021-01-14 07:14:45.332 INFO 14528 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2021-01-14 07:14:45.334 INFO 14528 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5313 ms 2021-01-14 07:14:46.593 INFO 14528 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2021-01-14 07:14:47.147 INFO 14528 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator' 2021-01-14 07:14:47.331 INFO 14528 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2021-01-14 07:14:47.336 INFO 14528 --- [ main] c.i.s.a.SpringBootStudyApplication : Started SpringBootStudyApplication in 8.317 seconds (JVM running for 9.589)
3.2 第二种启动方式:(通过api调用应用行为方式启动)
顶类:
package com.imooc.springboot.application; import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; /** * SpringBootApplication * * @author 魏豆豆 * @date 2021/1/13 */ @SpringBootApplication public class SpringBootStudyApplication { public static void main(String [] args){ //第一种方式启动 //SpringApplication.run(SpringBootStudyApplication.class,args); //第二种方式启动 SpringApplication springApplication = new SpringApplication(SpringBootStudyApplication.class); //关掉打印logo相关日志 springApplication.setBannerMode(Banner.Mode.OFF); //非wub启动,控制台启动后会关闭,不会一直保持开启状态,此配置关闭能打印端口等配置信息 springApplication.setWebApplicationType(WebApplicationType.NONE); springApplication.run(args); //第三种方式启动 链式调用 /* new SpringApplicationBuilder(SpringBootStudyApplication.class) .bannerMode(Banner.Mode.OFF) .web(WebApplicationType.NONE).run(args);*/ } }
打印日志:
D:\java\jdk\jdk8\jdk\bin\java.exe "-javaagent:D:\java\devolopKit\idea\anZh\IntelliJ IDEA Community Edition 2018.1.4\lib\idea_rt.jar=59101:D:\java\devolopKit\idea\anZh\IntelliJ IDEA Community Edition 2018.1.4\bin" -Dfile.encoding=UTF-8 -classpath D:\java\jdk\jdk8\jdk\jre\lib\charsets.jar;D:\java\jdk\jdk8\jdk\jre\lib\deploy.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\access-bridge-64.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\cldrdata.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\dnsns.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\jaccess.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\jfxrt.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\localedata.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\nashorn.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunec.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunjce_provider.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunmscapi.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunpkcs11.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\zipfs.jar;D:\java\jdk\jdk8\jdk\jre\lib\javaws.jar;D:\java\jdk\jdk8\jdk\jre\lib\jce.jar;D:\java\jdk\jdk8\jdk\jre\lib\jfr.jar;D:\java\jdk\jdk8\jdk\jre\lib\jfxswt.jar;D:\java\jdk\jdk8\jdk\jre\lib\jsse.jar;D:\java\jdk\jdk8\jdk\jre\lib\management-agent.jar;D:\java\jdk\jdk8\jdk\jre\lib\plugin.jar;D:\java\jdk\jdk8\jdk\jre\lib\resources.jar;D:\java\jdk\jdk8\jdk\jre\lib\rt.jar;F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study\target\classes;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.1.4.RELEASE\spring-boot-starter-web-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter\2.1.4.RELEASE\spring-boot-starter-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot\2.1.4.RELEASE\spring-boot-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.1.4.RELEASE\spring-boot-autoconfigure-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.1.4.RELEASE\spring-boot-starter-logging-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\weijingli\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\weijingli\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.11.2\log4j-to-slf4j-2.11.2.jar;C:\Users\weijingli\.m2\repository\org\apache\logging\log4j\log4j-api\2.11.2\log4j-api-2.11.2.jar;C:\Users\weijingli\.m2\repository\org\slf4j\jul-to-slf4j\1.7.26\jul-to-slf4j-1.7.26.jar;C:\Users\weijingli\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\weijingli\.m2\repository\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.1.4.RELEASE\spring-boot-starter-json-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.8\jackson-databind-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.8\jackson-core-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.8\jackson-datatype-jdk8-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.8\jackson-datatype-jsr310-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.8\jackson-module-parameter-names-2.9.8.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.1.4.RELEASE\spring-boot-starter-tomcat-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.17\tomcat-embed-core-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.17\tomcat-embed-el-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.17\tomcat-embed-websocket-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.16.Final\hibernate-validator-6.0.16.Final.jar;C:\Users\weijingli\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\weijingli\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\classmate\1.4.0\classmate-1.4.0.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-web\5.1.6.RELEASE\spring-web-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-beans\5.1.6.RELEASE\spring-beans-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-webmvc\5.1.6.RELEASE\spring-webmvc-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-aop\5.1.6.RELEASE\spring-aop-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-context\5.1.6.RELEASE\spring-context-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-expression\5.1.6.RELEASE\spring-expression-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\projectlombok\lombok\1.18.6\lombok-1.18.6.jar;C:\Users\weijingli\.m2\repository\org\slf4j\slf4j-api\1.7.26\slf4j-api-1.7.26.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-core\5.1.6.RELEASE\spring-core-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-jcl\5.1.6.RELEASE\spring-jcl-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\com\alibaba\fastjson\1.2.31\fastjson-1.2.31.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-configuration-processor\2.1.4.RELEASE\spring-boot-configuration-processor-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-actuator\2.1.4.RELEASE\spring-boot-starter-actuator-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-actuator-autoconfigure\2.1.4.RELEASE\spring-boot-actuator-autoconfigure-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-actuator\2.1.4.RELEASE\spring-boot-actuator-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\io\micrometer\micrometer-core\1.1.4\micrometer-core-1.1.4.jar;C:\Users\weijingli\.m2\repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;C:\Users\weijingli\.m2\repository\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar com.imooc.springboot.application.SpringBootStudyApplication 2021-01-14 07:15:35.944 INFO 15928 --- [ main] c.i.s.a.SpringBootStudyApplication : Starting SpringBootStudyApplication on DESKTOP-A08HONB with PID 15928 (F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study\target\classes started by weijingli in F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study) 2021-01-14 07:15:35.951 INFO 15928 --- [ main] c.i.s.a.SpringBootStudyApplication : No active profile set, falling back to default profiles: default 2021-01-14 07:15:39.933 INFO 15928 --- [ main] c.i.s.a.SpringBootStudyApplication : Started SpringBootStudyApplication in 4.836 seconds (JVM running for 6.158) Process finished with exit code 0
3.3 第三种启动方式:(spingapplicationbuilder 链式调用)
顶类:
package com.imooc.springboot.application; import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; /** * SpringBootApplication * * @author 魏豆豆 * @date 2021/1/13 */ @SpringBootApplication public class SpringBootStudyApplication { public static void main(String [] args){ //第一种方式启动 //SpringApplication.run(SpringBootStudyApplication.class,args); //第二种方式启动 /*SpringApplication springApplication = new SpringApplication(SpringBootStudyApplication.class); //关掉打印logo相关日志 springApplication.setBannerMode(Banner.Mode.OFF); //非web启动,控制台启动后会关闭,不会一直保持开启状态,此配置关闭还能打印端口等信息 springApplication.setWebApplicationType(WebApplicationType.NONE); springApplication.run(args);*/ //第三种方式启动 链式调用 new SpringApplicationBuilder(SpringBootStudyApplication.class) .bannerMode(Banner.Mode.OFF) .web(WebApplicationType.NONE).run(args); } }
打印日志:
D:\java\jdk\jdk8\jdk\bin\java.exe "-javaagent:D:\java\devolopKit\idea\anZh\IntelliJ IDEA Community Edition 2018.1.4\lib\idea_rt.jar=59250:D:\java\devolopKit\idea\anZh\IntelliJ IDEA Community Edition 2018.1.4\bin" -Dfile.encoding=UTF-8 -classpath D:\java\jdk\jdk8\jdk\jre\lib\charsets.jar;D:\java\jdk\jdk8\jdk\jre\lib\deploy.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\access-bridge-64.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\cldrdata.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\dnsns.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\jaccess.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\jfxrt.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\localedata.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\nashorn.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunec.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunjce_provider.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunmscapi.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\sunpkcs11.jar;D:\java\jdk\jdk8\jdk\jre\lib\ext\zipfs.jar;D:\java\jdk\jdk8\jdk\jre\lib\javaws.jar;D:\java\jdk\jdk8\jdk\jre\lib\jce.jar;D:\java\jdk\jdk8\jdk\jre\lib\jfr.jar;D:\java\jdk\jdk8\jdk\jre\lib\jfxswt.jar;D:\java\jdk\jdk8\jdk\jre\lib\jsse.jar;D:\java\jdk\jdk8\jdk\jre\lib\management-agent.jar;D:\java\jdk\jdk8\jdk\jre\lib\plugin.jar;D:\java\jdk\jdk8\jdk\jre\lib\resources.jar;D:\java\jdk\jdk8\jdk\jre\lib\rt.jar;F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study\target\classes;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.1.4.RELEASE\spring-boot-starter-web-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter\2.1.4.RELEASE\spring-boot-starter-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot\2.1.4.RELEASE\spring-boot-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.1.4.RELEASE\spring-boot-autoconfigure-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.1.4.RELEASE\spring-boot-starter-logging-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\weijingli\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\weijingli\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.11.2\log4j-to-slf4j-2.11.2.jar;C:\Users\weijingli\.m2\repository\org\apache\logging\log4j\log4j-api\2.11.2\log4j-api-2.11.2.jar;C:\Users\weijingli\.m2\repository\org\slf4j\jul-to-slf4j\1.7.26\jul-to-slf4j-1.7.26.jar;C:\Users\weijingli\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\weijingli\.m2\repository\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.1.4.RELEASE\spring-boot-starter-json-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.8\jackson-databind-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.8\jackson-core-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.8\jackson-datatype-jdk8-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.8\jackson-datatype-jsr310-2.9.8.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.8\jackson-module-parameter-names-2.9.8.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.1.4.RELEASE\spring-boot-starter-tomcat-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.17\tomcat-embed-core-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.17\tomcat-embed-el-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.17\tomcat-embed-websocket-9.0.17.jar;C:\Users\weijingli\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.16.Final\hibernate-validator-6.0.16.Final.jar;C:\Users\weijingli\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\weijingli\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\weijingli\.m2\repository\com\fasterxml\classmate\1.4.0\classmate-1.4.0.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-web\5.1.6.RELEASE\spring-web-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-beans\5.1.6.RELEASE\spring-beans-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-webmvc\5.1.6.RELEASE\spring-webmvc-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-aop\5.1.6.RELEASE\spring-aop-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-context\5.1.6.RELEASE\spring-context-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-expression\5.1.6.RELEASE\spring-expression-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\projectlombok\lombok\1.18.6\lombok-1.18.6.jar;C:\Users\weijingli\.m2\repository\org\slf4j\slf4j-api\1.7.26\slf4j-api-1.7.26.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-core\5.1.6.RELEASE\spring-core-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\spring-jcl\5.1.6.RELEASE\spring-jcl-5.1.6.RELEASE.jar;C:\Users\weijingli\.m2\repository\com\alibaba\fastjson\1.2.31\fastjson-1.2.31.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-configuration-processor\2.1.4.RELEASE\spring-boot-configuration-processor-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-starter-actuator\2.1.4.RELEASE\spring-boot-starter-actuator-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-actuator-autoconfigure\2.1.4.RELEASE\spring-boot-actuator-autoconfigure-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\org\springframework\boot\spring-boot-actuator\2.1.4.RELEASE\spring-boot-actuator-2.1.4.RELEASE.jar;C:\Users\weijingli\.m2\repository\io\micrometer\micrometer-core\1.1.4\micrometer-core-1.1.4.jar;C:\Users\weijingli\.m2\repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;C:\Users\weijingli\.m2\repository\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar com.imooc.springboot.application.SpringBootStudyApplication 2021-01-14 07:16:45.756 INFO 20384 --- [ main] c.i.s.a.SpringBootStudyApplication : Starting SpringBootStudyApplication on DESKTOP-A08HONB with PID 20384 (F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study\target\classes started by weijingli in F:\kewai\SpringCloud\laoqin\chapter_3\imooc_springboot_study) 2021-01-14 07:16:45.763 INFO 20384 --- [ main] c.i.s.a.SpringBootStudyApplication : No active profile set, falling back to default profiles: default 2021-01-14 07:16:49.078 INFO 20384 --- [ main] c.i.s.a.SpringBootStudyApplication : Started SpringBootStudyApplication in 4.154 seconds (JVM running for 5.267) Process finished with exit code 0
诸葛