zoukankan      html  css  js  c++  java
  • Spring Boot 配置文件

    Spring Boot 的默认配置文件为 src/main/resources/application.properties;

    Spring Boot还支持YAML(Ain't a Markup Language)文件 ,以类似大纲的缩进形式来表示

    除了可以在Spring boot的配置文件中设置各个Starter模块中预定义的配置属性,可以增加自定属性,

    然后通过@Value 注解来加载这些自定义参数。

     

    @Value("${book.name}")

    配置文件中可以使用 ${random} 配置来产生随机的int,long,string 字符串等。

    #随机字符串
    com.blog.value=${random.value}

    使用命令行参数

        java -jar xxx.jar --server.port=8888 两个减号就是对application.properties 中的属性进行赋值的标示。

    多环境配置

        application-dev.properties:开发环境

        application-test.properties:测试环境

        application-prod.properties:生产环境

    然后在application.properties 文件中通过spring.profiles.active 属性来设置

        spring.profiles.active=test 就会加载application-test.properties配置文件中的内容。

  • 相关阅读:
    ARP 协议
    天梯赛L1 题解
    DNS域名系统
    LeetCode 三角形最小路径和
    sql注入漏洞的利用
    XSS漏洞防御
    忘记密码功能漏洞挖掘
    sql bypass
    Web环境搭建组合
    常用数据库的总结
  • 原文地址:https://www.cnblogs.com/taiguyiba/p/9147319.html
Copyright © 2011-2022 走看看