Springboot 程序启动日志分析

日志内容

通过对SpringBoot日志的分析,大致了解SpringBoot的基本运行过程。

E:\jdk\bin\java.exe "-javaagent:D:\Idea\lib\idea_rt.jar=61506:D:\Idea\bin" -Dfile.encoding=UTF-8 -classpath E:\jdk\jre\lib\charsets.jar;E:\jdk\jre\lib\ext\access-bridge-64.jar;E:\jdk\jre\lib\ext\cldrdata.jar;E:\jdk\jre\lib\ext\dnsns.jar;E:\jdk\jre\lib\ext\dtfj.jar;E:\jdk\jre\lib\ext\dtfjview.jar;E:\jdk\jre\lib\ext\jaccess.jar;E:\jdk\jre\lib\ext\localedata.jar;E:\jdk\jre\lib\ext\nashorn.jar;E:\jdk\jre\lib\ext\sunec.jar;E:\jdk\jre\lib\ext\sunjce_provider.jar;E:\jdk\jre\lib\ext\sunmscapi.jar;E:\jdk\jre\lib\ext\sunpkcs11.jar;E:\jdk\jre\lib\ext\traceformat.jar;E:\jdk\jre\lib\ext\zipfs.jar;E:\jdk\jre\lib\jce.jar;E:\jdk\jre\lib\jsse.jar;E:\jdk\jre\lib\management-agent.jar;E:\jdk\jre\lib\resources.jar;E:\jdk\jre\lib\rt.jar;E:\work\study\cloud\boot-env\target\classes;E:\mavenres\org\springframework\boot\spring-boot-starter-data-redis\2.3.3.RELEASE\spring-boot-starter-data-redis-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-starter\2.3.3.RELEASE\spring-boot-starter-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot\2.3.3.RELEASE\spring-boot-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-autoconfigure\2.3.3.RELEASE\spring-boot-autoconfigure-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-logging\2.3.3.RELEASE\spring-boot-starter-logging-2.3.3.RELEASE.jar;E:\mavenres\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;E:\mavenres\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;E:\mavenres\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;E:\mavenres\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;E:\mavenres\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;E:\mavenres\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\mavenres\org\springframework\spring-core\5.2.8.RELEASE\spring-core-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-jcl\5.2.8.RELEASE\spring-jcl-5.2.8.RELEASE.jar;E:\mavenres\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;E:\mavenres\org\springframework\data\spring-data-redis\2.3.3.RELEASE\spring-data-redis-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\data\spring-data-keyvalue\2.3.3.RELEASE\spring-data-keyvalue-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\data\spring-data-commons\2.3.3.RELEASE\spring-data-commons-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\spring-tx\5.2.8.RELEASE\spring-tx-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-oxm\5.2.8.RELEASE\spring-oxm-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-aop\5.2.8.RELEASE\spring-aop-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-context-support\5.2.8.RELEASE\spring-context-support-5.2.8.RELEASE.jar;E:\mavenres\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;E:\mavenres\io\lettuce\lettuce-core\5.3.3.RELEASE\lettuce-core-5.3.3.RELEASE.jar;E:\mavenres\io\netty\netty-common\4.1.51.Final\netty-common-4.1.51.Final.jar;E:\mavenres\io\netty\netty-handler\4.1.51.Final\netty-handler-4.1.51.Final.jar;E:\mavenres\io\netty\netty-resolver\4.1.51.Final\netty-resolver-4.1.51.Final.jar;E:\mavenres\io\netty\netty-buffer\4.1.51.Final\netty-buffer-4.1.51.Final.jar;E:\mavenres\io\netty\netty-codec\4.1.51.Final\netty-codec-4.1.51.Final.jar;E:\mavenres\io\netty\netty-transport\4.1.51.Final\netty-transport-4.1.51.Final.jar;E:\mavenres\io\projectreactor\reactor-core\3.3.9.RELEASE\reactor-core-3.3.9.RELEASE.jar;E:\mavenres\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-web\2.3.3.RELEASE\spring-boot-starter-web-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-json\2.3.3.RELEASE\spring-boot-starter-json-2.3.3.RELEASE.jar;E:\mavenres\com\fasterxml\jackson\core\jackson-databind\2.11.2\jackson-databind-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\core\jackson-annotations\2.11.2\jackson-annotations-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\core\jackson-core\2.11.2\jackson-core-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.2\jackson-datatype-jdk8-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.2\jackson-datatype-jsr310-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.2\jackson-module-parameter-names-2.11.2.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-tomcat\2.3.3.RELEASE\spring-boot-starter-tomcat-2.3.3.RELEASE.jar;E:\mavenres\org\apache\tomcat\embed\tomcat-embed-core\9.0.37\tomcat-embed-core-9.0.37.jar;E:\mavenres\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;E:\mavenres\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.37\tomcat-embed-websocket-9.0.37.jar;E:\mavenres\org\springframework\spring-web\5.2.8.RELEASE\spring-web-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-beans\5.2.8.RELEASE\spring-beans-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-webmvc\5.2.8.RELEASE\spring-webmvc-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-context\5.2.8.RELEASE\spring-context-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-expression\5.2.8.RELEASE\spring-expression-5.2.8.RELEASE.jar;E:\mavenres\org\mybatis\spring\boot\mybatis-spring-boot-starter\3.0.3\mybatis-spring-boot-starter-3.0.3.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-jdbc\2.3.3.RELEASE\spring-boot-starter-jdbc-2.3.3.RELEASE.jar;E:\mavenres\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;E:\mavenres\org\springframework\spring-jdbc\5.2.8.RELEASE\spring-jdbc-5.2.8.RELEASE.jar;E:\mavenres\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\3.0.3\mybatis-spring-boot-autoconfigure-3.0.3.jar;E:\mavenres\org\mybatis\mybatis\3.5.14\mybatis-3.5.14.jar;E:\mavenres\org\mybatis\mybatis-spring\3.0.3\mybatis-spring-3.0.3.jar;E:\mavenres\org\projectlombok\lombok\1.18.12\lombok-1.18.12.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-actuator\2.3.3.RELEASE\spring-boot-starter-actuator-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-actuator-autoconfigure\2.3.3.RELEASE\spring-boot-actuator-autoconfigure-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-actuator\2.3.3.RELEASE\spring-boot-actuator-2.3.3.RELEASE.jar;E:\mavenres\io\micrometer\micrometer-core\1.5.4\micrometer-core-1.5.4.jar;E:\mavenres\org\hdrhistogram\HdrHistogram\2.1.12\HdrHistogram-2.1.12.jar;E:\mavenres\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar com.yeegee.demo.YeegeeStarter

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.3.RELEASE)

2024-10-09 14:41:22.076  INFO 29936 --- [           main] com.yeegee.demo.YeegeeStarter            : Starting YeegeeStarter on 8RCF9JB with PID 29936 (E:\work\study\cloud\boot-env\target\classes started by ylf in E:\work\study\cloud)
2024-10-09 14:41:22.084  INFO 29936 --- [           main] com.yeegee.demo.YeegeeStarter            : No active profile set, falling back to default profiles: default
2024-10-09 14:41:24.773  INFO 29936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2024-10-09 14:41:24.777  INFO 29936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2024-10-09 14:41:24.843  INFO 29936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 19ms. Found 0 Redis repository interfaces.
2024-10-09 14:41:26.693  INFO 29936 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2024-10-09 14:41:26.711  INFO 29936 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-10-09 14:41:26.711  INFO 29936 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
2024-10-09 14:41:26.855  INFO 29936 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-10-09 14:41:26.855  INFO 29936 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4278 ms
2024-10-09 14:41:27.618  INFO 29936 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2024-10-09 14:41:27.890  WARN 29936 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2024-10-09 14:41:27.891  INFO 29936 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2024-10-09 14:41:27.896  INFO 29936 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2024-10-09 14:41:27.937  INFO 29936 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2024-10-09 14:41:27.940 ERROR 29936 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).


Process finished with exit code 1

日志分析

第一句,看起来特别复杂,实际上简化一下就很明了了

简化前:


E:\jdk\bin\java.exe "-javaagent:D:\Idea\lib\idea_rt.jar=61506:D:\Idea\bin" -Dfile.encoding=UTF-8 -classpath E:\jdk\jre\lib\charsets.jar;E:\jdk\jre\lib\ext\access-bridge-64.jar;E:\jdk\jre\lib\ext\cldrdata.jar;E:\jdk\jre\lib\ext\dnsns.jar;E:\jdk\jre\lib\ext\dtfj.jar;E:\jdk\jre\lib\ext\dtfjview.jar;E:\jdk\jre\lib\ext\jaccess.jar;E:\jdk\jre\lib\ext\localedata.jar;E:\jdk\jre\lib\ext\nashorn.jar;E:\jdk\jre\lib\ext\sunec.jar;E:\jdk\jre\lib\ext\sunjce_provider.jar;E:\jdk\jre\lib\ext\sunmscapi.jar;E:\jdk\jre\lib\ext\sunpkcs11.jar;E:\jdk\jre\lib\ext\traceformat.jar;E:\jdk\jre\lib\ext\zipfs.jar;E:\jdk\jre\lib\jce.jar;E:\jdk\jre\lib\jsse.jar;E:\jdk\jre\lib\management-agent.jar;E:\jdk\jre\lib\resources.jar;E:\jdk\jre\lib\rt.jar;E:\work\study\cloud\boot-env\target\classes;E:\mavenres\org\springframework\boot\spring-boot-starter-data-redis\2.3.3.RELEASE\spring-boot-starter-data-redis-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-starter\2.3.3.RELEASE\spring-boot-starter-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot\2.3.3.RELEASE\spring-boot-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-autoconfigure\2.3.3.RELEASE\spring-boot-autoconfigure-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-logging\2.3.3.RELEASE\spring-boot-starter-logging-2.3.3.RELEASE.jar;E:\mavenres\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;E:\mavenres\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;E:\mavenres\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;E:\mavenres\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;E:\mavenres\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;E:\mavenres\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\mavenres\org\springframework\spring-core\5.2.8.RELEASE\spring-core-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-jcl\5.2.8.RELEASE\spring-jcl-5.2.8.RELEASE.jar;E:\mavenres\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;E:\mavenres\org\springframework\data\spring-data-redis\2.3.3.RELEASE\spring-data-redis-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\data\spring-data-keyvalue\2.3.3.RELEASE\spring-data-keyvalue-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\data\spring-data-commons\2.3.3.RELEASE\spring-data-commons-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\spring-tx\5.2.8.RELEASE\spring-tx-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-oxm\5.2.8.RELEASE\spring-oxm-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-aop\5.2.8.RELEASE\spring-aop-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-context-support\5.2.8.RELEASE\spring-context-support-5.2.8.RELEASE.jar;E:\mavenres\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;E:\mavenres\io\lettuce\lettuce-core\5.3.3.RELEASE\lettuce-core-5.3.3.RELEASE.jar;E:\mavenres\io\netty\netty-common\4.1.51.Final\netty-common-4.1.51.Final.jar;E:\mavenres\io\netty\netty-handler\4.1.51.Final\netty-handler-4.1.51.Final.jar;E:\mavenres\io\netty\netty-resolver\4.1.51.Final\netty-resolver-4.1.51.Final.jar;E:\mavenres\io\netty\netty-buffer\4.1.51.Final\netty-buffer-4.1.51.Final.jar;E:\mavenres\io\netty\netty-codec\4.1.51.Final\netty-codec-4.1.51.Final.jar;E:\mavenres\io\netty\netty-transport\4.1.51.Final\netty-transport-4.1.51.Final.jar;E:\mavenres\io\projectreactor\reactor-core\3.3.9.RELEASE\reactor-core-3.3.9.RELEASE.jar;E:\mavenres\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-web\2.3.3.RELEASE\spring-boot-starter-web-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-json\2.3.3.RELEASE\spring-boot-starter-json-2.3.3.RELEASE.jar;E:\mavenres\com\fasterxml\jackson\core\jackson-databind\2.11.2\jackson-databind-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\core\jackson-annotations\2.11.2\jackson-annotations-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\core\jackson-core\2.11.2\jackson-core-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.2\jackson-datatype-jdk8-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.2\jackson-datatype-jsr310-2.11.2.jar;E:\mavenres\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.2\jackson-module-parameter-names-2.11.2.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-tomcat\2.3.3.RELEASE\spring-boot-starter-tomcat-2.3.3.RELEASE.jar;E:\mavenres\org\apache\tomcat\embed\tomcat-embed-core\9.0.37\tomcat-embed-core-9.0.37.jar;E:\mavenres\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;E:\mavenres\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.37\tomcat-embed-websocket-9.0.37.jar;E:\mavenres\org\springframework\spring-web\5.2.8.RELEASE\spring-web-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-beans\5.2.8.RELEASE\spring-beans-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-webmvc\5.2.8.RELEASE\spring-webmvc-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-context\5.2.8.RELEASE\spring-context-5.2.8.RELEASE.jar;E:\mavenres\org\springframework\spring-expression\5.2.8.RELEASE\spring-expression-5.2.8.RELEASE.jar;E:\mavenres\org\mybatis\spring\boot\mybatis-spring-boot-starter\3.0.3\mybatis-spring-boot-starter-3.0.3.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-jdbc\2.3.3.RELEASE\spring-boot-starter-jdbc-2.3.3.RELEASE.jar;E:\mavenres\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;E:\mavenres\org\springframework\spring-jdbc\5.2.8.RELEASE\spring-jdbc-5.2.8.RELEASE.jar;E:\mavenres\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\3.0.3\mybatis-spring-boot-autoconfigure-3.0.3.jar;E:\mavenres\org\mybatis\mybatis\3.5.14\mybatis-3.5.14.jar;E:\mavenres\org\mybatis\mybatis-spring\3.0.3\mybatis-spring-3.0.3.jar;E:\mavenres\org\projectlombok\lombok\1.18.12\lombok-1.18.12.jar;E:\mavenres\org\springframework\boot\spring-boot-starter-actuator\2.3.3.RELEASE\spring-boot-starter-actuator-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-actuator-autoconfigure\2.3.3.RELEASE\spring-boot-actuator-autoconfigure-2.3.3.RELEASE.jar;E:\mavenres\org\springframework\boot\spring-boot-actuator\2.3.3.RELEASE\spring-boot-actuator-2.3.3.RELEASE.jar;E:\mavenres\io\micrometer\micrometer-core\1.5.4\micrometer-core-1.5.4.jar;E:\mavenres\org\hdrhistogram\HdrHistogram\2.1.12\HdrHistogram-2.1.12.jar;E:\mavenres\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar com.yeegee.demo.YeegeeStarter

简化后:

E:\jdk\bin\java.exe "-javaagent:D:\Idea\lib\idea_rt.jar=61506:D:\Idea\bin" -Dfile.encoding=UTF-8 -classpath xxx com.yeegee.demo.YeegeeStarter

该命令只是启动JAVA进程,对应提供了几个启动参数 -javaagent 指定JAVA编程语言代理 -Dfile.encoding 指定字符编码格式 -classpath 指定类加载路径

第二句

打印出来的是默认的SPRING BOOT 打印体图案 如果你想修改它,可以在resources目录下,新增一个banner.txt文件 把你想要打的字,通过网站 http://patorjk.com/software/taag/ 生成出对应的内容 再粘贴到刚刚新建的banner.txt文件中。 那么再次重启,你就可以看到,已经改成了跟你的banner.txt文件内容一样的图案。

第三句

2024-10-09 14:41:22.076  INFO 29936 --- [           main] com.yeegee.demo.YeegeeStarter            : Starting YeegeeStarter on 8RCF9JB with PID 29936 (E:\work\study\cloud\boot-env\target\classes started by ylf in E:\work\study\cloud)

告诉你启动程序时获取到的机器编码和程序运行的进程ID

第四句


2024-10-09 14:41:22.084  INFO 29936 --- [           main] com.yeegee.demo.YeegeeStarter            : No active profile set, falling back to default profiles: default

没有设置profile,使用默认配置执行

第五句

2024-10-09 14:41:24.773  INFO 29936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!

提示找到了多个数据模块,进入严格存储库配置模式,如果不愿意看到这行提示,可以增加类似以下的配置来解决

@SpringBootApplication(exclude = { RedisRepositoriesAutoConfiguration.class })

第6句

2024-10-09 14:41:24.777  INFO 29936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.

以默认模式启动Spring Data Redis存储库。

第七句

2024-10-09 14:41:24.843  INFO 29936 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 19ms. Found 0 Redis repository interfaces.

完成数据存储库扫描,发现0个redis存储库

第七句

2024-10-09 14:41:26.693  INFO 29936 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

提示启动容器类型(Tomcat),占用端口(8080)等信息

第八-十一句

2024-10-09 14:41:26.711  INFO 29936 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-10-09 14:41:26.711  INFO 29936 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
2024-10-09 14:41:26.855  INFO 29936 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-10-09 14:41:26.855  INFO 29936 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4278 ms

打印启动tomcat情况的日志信息

第十二句

2024-10-09 14:41:27.618  INFO 29936 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'

初始化执行服务 applicationTaskExecutor

第十三句

2024-10-09 14:41:27.890  WARN 29936 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

这里发生了一个异常,看到dataSource,很显然就知道是数据库连接配置出现了异常

之后的每句就没必要一一去解释了,都是由于该异常而输出的日志信息。

因为我这里加载了mysql的驱动,但是没有提供相应的配置选项,所以,结合后面的报错也可以看出,是找不到配置信息导致的异常。

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

从上面这行提示可以看出,必须要配置URL等相关数据库参数。这里提供一个数据库配置的示例代码,你可以自己试试。

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
    username: yeegee
    password: yeegee!@#

总结

从直观的日志上来看,程序运行,首先启动JAVA进程,然后进入SpringBoot的引擎,打印banner信息,打印程序运行的相关信息,再根据配置的运行模式,来调取相应的配置文件,加载redis ,启动web容器,加载数据库连接等操作。 当然也会根据Spring的注解等信息,去自动装配一些对象。通过日志,我们能够了解更多的运行信息或是调试信息,对辅助我们的业务逻辑处理和问题排查有很大的帮助,所以适当的打印日志,可能会提高我们的处理问题的效率。