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

spring boot -Properties & configuration的更多相关文章

  1. 玩转spring boot——properties配置

    前言 在以往的java开发中,程序员最怕大量的配置,是因为配置一多就不好统一管理,经常出现找不到配置的情况.而项目中,从开发测试环境到生产环境,往往需要切换不同的配置,如测试数据库连接换成生产数据库连 ...

  2. Spring Boot Externalized Configuration

    https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html Ex ...

  3. Spring Boot通过Configuration配置多数据源

    本文结合SpringBoot + MyBatis + MySql进行多数据源配置,DataSource信息采用自定义dataSource.properties进行配置. 1.文件结构如下: 2.1 p ...

  4. Spring boot的@Configuration

    就在我惊艳于spring 4的AbstractAnnotationConfigDispatcherServletInitializer小巧简洁(如下)的时候却发现spring boot下面竟然无效. ...

  5. spring boot properties

    [转载] 代码从开发到测试要经过各种环境,开发环境,测试环境,demo环境,线上环境,各种环境的配置都不一样,同时要方便各种角色如运维,接口测试, 功能测试,全链路测试的配置,hardcode 肯定不 ...

  6. Spring boot 使用 configuration 获取的属性为 null

    1. 未设置 getter(),setter()方法,导致属性值注入失败: 2. spring 未扫描到该组件,在其他类中注入该对象失败,可在配置类添加 @configuration 或者 @comp ...

  7. spring boot properties文件与yaml文件的区别

    编写是没有提示的话在pom中添加依赖,如下: <!-- 配置文件处理器 编写配置时会有提示 --> <dependency> <groupId>org.spring ...

  8. idea 启动项目提示 Command line is too long. Shorten command line for Application or also for Spring Boot default configuration.

    在.idea 文件夹中打开workspace.xml文件找到<component name="PropertiesComponent">,在标签里加一行  <pr ...

  9. 【springcloud】【idea】启动服务报错Command line is too long. Shorten command line for XXXApplication or also for Spring Boot default configuration.

    在workspace.xml 在标签<component name="PropertiesComponent">里 添加<property name=" ...

随机推荐

  1. Java线程专栏文章汇总

        转载自 http://blog.csdn.net/ghsau/article/details/17609747 JDK5.0之前传统线程        Java线程(一):线程安全与不安全 J ...

  2. Android群英传笔记——第三章:Android控件架构与自定义控件讲解

    Android群英传笔记--第三章:Android控件架构与自定义控件讲解 真的很久没有更新博客了,三四天了吧,搬家干嘛的,心累,事件又很紧,抽时间把第三章大致的看完了,当然,我还是有一点View的基 ...

  3. 最新App Store审核10大被拒理由

    最近,苹果在官网给出了截至2015年2月份应用被拒绝的十大理由,其中50%以上的应用被拒绝都是因为这10个原因,其中7个理由和2014年相同,其中排名前三的原因分别是:需要补充更多信息.存在明显的bu ...

  4. 布局display属性(一)--【Flex】

    一.Flex 布局是什么? Flex 是 Flexible Box 的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性. 任何一个容器都可以指定为 Flex 布局. .box ...

  5. NewLife.Net——开始网络编程

    网络编程的重要性就不说了,先上源码:https://github.com/nnhy/NewLife.Net.Tests 一个服务端,就是监听一些端口,接收客户端连接和数据,进行处理,然后响应. /// ...

  6. Android Studio集成Lombok Plugin

    Lombok是Android Studio名列前茅的插件,有啥用,看这个:http://www.blogjava.NET/fancydeepin/archive/2012/07/12/lombok.h ...

  7. Ubuntu 18.04 启动root账号并授权远程登录

    Ubuntu 18.04 刚刚上市2个月,下载安装,尝尝鲜~ 安装界面看上去舒服许多, 安装的速度也较之前17.04 和16.04 都快了许多.抱歉,未截图. Ubuntu 安装完成后默认不启动roo ...

  8. myeclipse2014鼠标单击后光标位置背景底色为白色太难看,行号显示

    Java文件的修改方法: window--Preferences--Java--Editor--Mark Occurences JS文件中点击字符串就会变成白色背景 JS文件字体颜色的修改 windo ...

  9. C++中遍历读取数组中的元素

    答案来源:https://zhidao.baidu.com/question/187071815.html 对于字符数组str[N],判断方法有以下三种: 第一种:用库函数strlen 1 len = ...

  10. 有关于二分搜索的常见问题(java实现)

    前言: 二分搜索是一个非常常见的面试题目,它具有非常广泛的用途.熟练的掌握二分搜索的基本形式和他的变式是非常重要的.接下来我们将使用java实现一些常见的有关二分搜索的问题. 具体内容: 1.二分搜索 ...