application.properties配置文件


SpringBoot可以識別兩種格式的配置文件,分別是yml文件與properties文件,可以將application.properties文件換成application.yml

application.properties默認放在:src/main/resource目錄下,SpringBoot會自動加載

比較常用的配置

server.port=xxxx #端口

系統屬性/變量

spring.profiles.active=xxx

該系統變量可以指明要使用的配置文件,一般應用於多環境配置分離

如:

  spring.profiles.active=dev

  在啟動時會加載application-dev.properties配置文件,和application.properties在同一目錄下

mysql基本配置

引入spring-boot-starter-jdbc

spring.datasource.url=jdbc:mysql://localhost:3306/dataname?serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

MyBatis配置

引入mybatis-spring-boot-starter

mybatis.config-location=classpath:mybatis/mybatis-config.xml  #放在resources/mybatis/mybatis-config.xml中
mybatis.mapper-locations= classpath:mybatis/mapper/*.xml
mybatis.type-aliases-package=com.form.model #類型轉換器包,多個逗號隔開

 

redis基本配置

引入spring-boot-starter-data-redis

spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=
spring.redis.timeout=10000

banner配置

項目啟動時打印的一堆符號

banner.location=xxx.txt  #可以自定義輸出信息的位置
banner.charset=utf-8  #指定編碼格式
spring.main.banner-mode=console/off    #banner圖開啟或者打印模式

 字符畫生成的網站

http://www.network-science.de/ascii/
http://patorjk.com/software/taag/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM