日志
java -Dlogging.level.org.springframework=debug -jar app.jar
-Dlogging.level.org.springframework=debug启动是时候采用debug模式,便于查看debug日志
参考: https://www.baeldung.com/spring-boot-logging
从jar外部加载参数配置
参考: https://www.baeldung.com/spring-properties-file-outside-jar
表示读取启动的时候读取/Users/home/config/jdbc.properties
java -jar app.jar --spring.config.location=file:///Users/home/config/jdbc.properties
或
java -Dspring.config.location=file:///Users/home/jdbc.properties -jar app.jar
表示读取启动的时候读取/Users/home/config中的jdbc.properties和application.properties:
java -jar app.jar --spring.config.name=application,jdbc --spring.config.location=file:///Users/home/config
或
java -Dspring.config.name=application,jdbc -Dspring.config.location=file:///Users/home/config -jar app.jar
加载外部application.properties 或 application.yml 的顺序
By convention, Spring Boot looks for an externalized configuration file – application.properties or application.yml – in 4 predetermined locations in the following order of precedence:
- A /config subdirectory of the current directory
- The current directory
- A classpath /config package
- The classpath root
Therefore, a property defined in application.properties and placed in the /config subdirectory of the current directory will be loaded. This will also override properties in other locations in case of a collision.
在springboot2.0之后,采用的默认数据库连接池就是Hikari
Hikari连接池的读取的是 spring.datasource.jdbc-url,而不是 spring.datasource.url, 配置的时候一定要注意。 (当出现jar包外部的application.yml没有覆盖,jar包内部的application.yml假像时), 检查一下内部和外部的参数名一致。外部的application.yml是一定能覆盖内部的application.yml配置的。