記錄是為了更好的成長!
1、數據庫連接配置
#描述數據源 spring.datasource.url=jdbc:mysql://localhost:3306/tanglong?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia spring.datasource.username=root spring.datasource.password=0000
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.type = com.alibaba.druid.pool.DruidDataSource
#http編碼設置
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
2、thymeleaf組件配置
#spring.thymeleaf.cache=false
#spring.thymeleaf.prefix=classpath:/templates/
#spring.thymeleaf.check-template-location=true
#spring.thymeleaf.suffix=.html
#spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf.content-type=text/html
#spring.thymeleaf.mode=HTML5
3、定義banner輸出信息
#可以自定義輸出信息的位置
#banner.location=xxx.txt
#指定編碼格式
#banner.charset=utf-8
#banner圖開啟或者打印模式
#spring.main.banner-mode=console/off
4、配置端口和項目名訪問
#指定springboot內嵌容器啟動的端口,默認使用tomcat容器時在8080端口
#server.port=8081
#配置項目訪問路徑
#server.servlet.context-path=/boot
5、數據持久化配置
#是否打印sql語句
#spring.jpa.show-sql= true
#mybatis配置文件路徑
#mybatis.config-location=classpath:MyBatis.xml
#mybatis.mapper-locaitons=classpath:mybatis/mappings/*.xml
#打印myBatis的sql語句 com.demo.mapper 為包名
logging.level.com.demo.mapper=debug
#別名實體包,多個逗號隔開
#mybatis.type-aliases-package=com.user.bean
6、文件上傳大小配置
spring.servlet.multipart.maxFileSize=30MB spring.servlet.multipart.maxRequestSize=30MB
7、多種開發環境配置
#開發/測試/生產環境分別對應dev/test/prod,可以自由定義,當前配置為開發環境 spring.profiles.active=dev
不同環境中的配置信息可以寫在其他文件中
application-test.properties 或者 application-prod.properties
8、測試生產日志分離
在logback-spring.xml
文件中配置:
<!-- 測試環境+開發環境. 多個使用逗號隔開. --> <springProfile name="test,dev"> <logger name="org.springframework.web" level="DEBUG"/> <logger name="me.yidasanqian" level="DEBUG"/> </springProfile> <!-- 生產環境. --> <springProfile name="prod"> <logger name="org.springframework.web" level="INFO"/> <logger name="me.yidasanqian" level="INFO"/> </springProfile>
最后在application.properties
文件中配置:
logging.config=classpath:logback-spring.xml
以上內容代表個人觀點,僅供參考,不喜勿噴。。。