美文网首页WEB
多配制文件

多配制文件

作者: 我问你瓜保熟吗 | 来源:发表于2019-03-19 22:22 被阅读7次

    1、application.properties

    name=这是默认配置文件
    spring.profiles.active=prod
    

    2、application-dev.properties

    name=这是开发环境配置文件
    
    server.port=8080
    
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://12.132.1.71:3306/test?useUnicode=true&characterEncoding=UTF8&useSSL=false&serverTimezone=UTC
    spring.datasource.username=root
    spring.datasource.password=root
    
    # thymeleaf配置,开发环境不启用缓存,正式环境下请启用缓存,提高性能
    spring.thymeleaf.cache=false
    # thymeleaf对html元素格式要求严格,设置它的mode为HTML,忘记结束标签后不会报错
    spring.thymeleaf.mode=HTML
    
    # 如果要在mapper.xml里使用model,不加此项要写完整路径com.....model...
    mybatis.type-aliases-package=com.springboot.pagehelper.model
    # 如果要将mapper的xml文件放在 resources目录下,对mybatis 进行如下配置
    mybatis.mapper-locations=classpath:mapper/*.xml
    

    3、applicationprod.properties

    name=这是生产环境配置文件
    
    server.port=80
    
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://11.122.1.71:3306/test?useUnicode=true&characterEncoding=UTF8&useSSL=false&serverTimezone=UTC
    spring.datasource.username=root
    spring.datasource.password=root
    
    
    # thymeleaf对html元素格式要求严格,设置它的mode为HTML,忘记结束标签后不会报错
    spring.thymeleaf.mode=HTML
    
    
    # 如果要在mapper.xml里使用model,不加此项要写完整路径com.....model...
    mybatis.type-aliases-package=com.springboot.pagehelper.model
    # 如果要将mapper的xml文件放在 resources目录下,对mybatis 进行如下配置
    mybatis.mapper-locations=classpath:mapper/*.xml
    

    4、打完jar包后用jar命令修改配置文件

    java -jar PropertiesSpringBoot-0.0.1-SNAPSHOT.jar --spring.profiles.active=test

    相关文章

      网友评论

        本文标题:多配制文件

        本文链接:https://www.haomeiwen.com/subject/wfeomqtx.html