分享

1、springBoot中application.properties的常用配置

 一生有你__ 2019-05-10

记录是为了更好的成长!

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
复制代码

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、多种开发环境配置

#开发/测试/生产环境分别对应dev/test/prod,可以自由定义,当前配置为开发环境
spring.profiles.active=dev

不同环境中的配置信息可以写在其他文件中
application-test.properties 或者 application-prod.properties

 

 

 

以上内容代表个人观点,仅供参考,不喜勿喷。。。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多