springBoot中application.properties的常⽤配置
记录是为了更好的成长!
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 = sql.cj.jdbc.Driver
pe = com.alibaba.druid.pool.DruidDataSource
#http编码设置
spring怎么读取ding.charset=UTF-8
abled=true
ding.force=true
2、thymeleaf组件配置
#spring.thymeleaf.cache=false
#spring.thymeleaf.prefix=classpath:/templates/
#spring.thymeleaf.check-template-location=true
#spring.thymeleaf.suffix=.html
#ding=UTF-8
#t-type=text/html
#de=HTML5
3、定义banner输出信息
#可以⾃定义输出信息的位置
#banner.
#指定编码格式
#banner.charset=utf-8
#banner图开启或者打印模式
#spring.main.banner-mode=console/off
4、配置端⼝和项⽬名访问
#指定springboot内嵌容器启动的端⼝,默认使⽤tomcat容器时在8080端⼝
#server.port=8081
#配置项⽬访问路径
#t-path=/boot
5、数据持久化配置
#是否打印sql语句
#spring.jpa.show-sql= true
#mybatis配置⽂件路径
#fig-location=l
#mybatis.mapper-locaitons=classpath:mybatis/mappings/*.xml
#打印myBatis的sql语句 com.demo.mapper 为包名
logging.level.demo.mapper=debug
#别名实体包,多个逗号隔开
#pe-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、测试⽣产⽇志分离
在l⽂件中配置:
<!-- 测试环境+开发环境. 多个使⽤逗号隔开. -->
<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⽂件中配置:
以上内容代表个⼈观点,仅供参考,不喜勿喷。。。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论