zoukankan      html  css  js  c++  java
  • spring boot -Properties & configuration

    72. Properties & configuration
    72.1 Automatically expand properties at build time
    Rather than hardcoding some properties that are also specified in your project’s build configuration, you can automatically expand them using the existing build configuration instead. This is possible in both Maven and Gradle.

    72.1.1 Automatic property expansion using Maven

    You can automatically expand properties from the Maven project using resource filtering. If you use the spring-boot-starter-parent you can then refer to your Maven ‘project properties’ via @..@ placeholders, e.g.

    app.encoding=@project.build.sourceEncoding@
    app.java.version=@java.version@
    [Tip]
    The spring-boot:run can add src/main/resources directly to the classpath (for hot reloading purposes) if you enable the addResources flag. This circumvents the resource filtering and this feature. You can use the exec:java goal instead or customize the plugin’s configuration, see the plugin usage page for more details.
    If you don’t use the starter parent, in your pom.xml you need (inside the <build/> element):

    <resources>
    <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
    </resource>
    </resources>

    and (inside <plugins/>):

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.7</version>
    <configuration>
    <delimiters>
    <delimiter>@</delimiter>
    </delimiters>
    <useDefaultDelimiters>false</useDefaultDelimiters>
    </configuration>
    </plugin>


    [Note]
    The useDefaultDelimiters property is important if you are using standard Spring placeholders in your configuration (e.g. ${foo}). These may be expanded by the build if that property is not set to false.

     http://docs.spring.io/spring-boot/docs/1.5.2.RELEASE/reference/htmlsingle/#howto-automatic-expansion

  • 相关阅读:
    C++ string 类详解
    C语言 -- 字符串详解
    基本数据结构 -- 链表的遍历、查找、插入和删除
    Shell 基础 -- 总结几种括号、引号的用法
    用 C 语言描述几种排序算法
    Win10 + vs2017 编译并配置tesseract4.1.0
    前端如何引入vConsole
    php设计模式-数据对象映射模式
    PHP设计模式-策略模式
    PHP设计模式-适配器模式
  • 原文地址:https://www.cnblogs.com/softidea/p/6719587.html
Copyright © 2011-2022 走看看