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
spring boot -Properties & configuration的更多相关文章
- 玩转spring boot——properties配置
前言 在以往的java开发中,程序员最怕大量的配置,是因为配置一多就不好统一管理,经常出现找不到配置的情况.而项目中,从开发测试环境到生产环境,往往需要切换不同的配置,如测试数据库连接换成生产数据库连 ...
- Spring Boot Externalized Configuration
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html Ex ...
- Spring Boot通过Configuration配置多数据源
本文结合SpringBoot + MyBatis + MySql进行多数据源配置,DataSource信息采用自定义dataSource.properties进行配置. 1.文件结构如下: 2.1 p ...
- Spring boot的@Configuration
就在我惊艳于spring 4的AbstractAnnotationConfigDispatcherServletInitializer小巧简洁(如下)的时候却发现spring boot下面竟然无效. ...
- spring boot properties
[转载] 代码从开发到测试要经过各种环境,开发环境,测试环境,demo环境,线上环境,各种环境的配置都不一样,同时要方便各种角色如运维,接口测试, 功能测试,全链路测试的配置,hardcode 肯定不 ...
- Spring boot 使用 configuration 获取的属性为 null
1. 未设置 getter(),setter()方法,导致属性值注入失败: 2. spring 未扫描到该组件,在其他类中注入该对象失败,可在配置类添加 @configuration 或者 @comp ...
- spring boot properties文件与yaml文件的区别
编写是没有提示的话在pom中添加依赖,如下: <!-- 配置文件处理器 编写配置时会有提示 --> <dependency> <groupId>org.spring ...
- 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 ...
- 【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=" ...
随机推荐
- Linux常用命令(第二版) --权限管理命令
权限管理命令 1.chmod[change the permissions mode of a file] : /bin/chmod 语法: chmod [{ugo}{+-=}{rwx}] [文件或目 ...
- 第一个Polymer应用 - (2)创建你自己的元素
原文链接: Step 2: Your own element翻译日期: 2014年7月6日翻译人员: 铁锚通过上一节的学习和实践, 您已经完成了一个基本的应用程序结构(application stru ...
- 使用Android Studio手把手教你将应用打包+代码混淆
最近几天用Google的Design库写了个App,使用Android Studio将app打包时遇到的几个瓶颈,所以把详细步骤写入下来. AS中怎么获取应用签名 这和eclipse不同,eclips ...
- hadoop 数据倾斜
数据倾斜是指,map /reduce程序执行时,reduce节点大部分执行完毕,但是有一个或者几个reduce节点运行很慢,导致整个程序的处理时间很长,这是因为某一个key的条数比其他key多很多(有 ...
- Google主推-Android开发利器——Android Studio,这可能是最全的AS教程!
Android Studio使用手册 "工欲善其事必先利其器" 作为一个Android开发人员来说,一款好的开发工具也是相当重要的,在相当长的时间礼,Google都是基于Eclip ...
- unix命令自我总结
三种参数类型 1⃣时间日期: cal times time 2⃣文字处理: ctl+v 输入控制字符 ${#str} str字符串长度 expr length $abc 同上 typeset -i x ...
- 近期ubuntu 14.04 cpu占用高排障
近期linux使用总是cpu达到满值, 双核cpu其中一个核总是100%,另一个核正常.top之发现输入法框架fcitx满载,直接kill之,发现搜狗输入法不能用了,随即输入如下命令: fcitx f ...
- ruby中printf "%x"%-4为何会打印开头..
先看一下ruby中printf "%x" % -4的返回结果: irb(main):134:0> printf "%x\n" % -4 ..fc 前面的. ...
- 《深入理解Java虚拟机》读书笔记3--垃圾回收算法
转载:http://blog.csdn.net/tjiyu/article/details/53983064 下面先来了解Java虚拟机垃圾回收的几种常见算法:标记-清除算法.复制算法.标记-整理算法 ...
- Failed to create the Java Virtual Machine(zt)
http://lixueli26.iteye.com/blog/711152 在以下版本也发生类似情况,采用同样方法得以解决. 版本:eclipse-jee-indigo-win32 自己电脑上装的j ...