zoukankan      html  css  js  c++  java
  • 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 = 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

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

  • 相关阅读:
    美国常青小组:“4+2”,成功的企业的普遍特征
    与你的商业伙伴建立信任关系的12条准则
    成功12级跳:你还是穷人只因为你没有立下成为富人的目标
    生日与谁共
    猎取人心的36条黄金法则
    谢谢你能为我落泪
    要锤炼出营销魔法,口碑营销“无招胜有招”
    怎样成为下一个比尔·盖茨?总结决定他成功的几大要素
    只要你能够幸福
    史玉柱:创业不是靠忽悠,我的最后四个忠告
  • 原文地址:https://www.cnblogs.com/newbest/p/9975151.html
Copyright © 2011-2022 走看看