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=" ...
随机推荐
- LeetCode之“动态规划”:Best Time to Buy and Sell Stock I && II && III && IV
Best Time to Buy and Sell Stock I 题目链接 题目要求: Say you have an array for which the ith element is the ...
- PS 图像调整算法——阈值
PS里面这个算法,先将图像转成灰度图像,然后根据给定的阈值,大于该阈值的像素赋值为1,小于该阈值的赋值为0. if x>T, x=1; if x<T, x=0; 原图: 效果图:阈值为 1 ...
- linux内核自旋锁API
我们大概都了解,锁这种机制其实是为了保护临界区代码的,关于使用和定义,我总结的API如下: #include <linux/spinlock.h> 定义自旋锁 spinlock_t loc ...
- unix命令自我总结
三种参数类型 1⃣时间日期: cal times time 2⃣文字处理: ctl+v 输入控制字符 ${#str} str字符串长度 expr length $abc 同上 typeset -i x ...
- 云技术:弹性计算ECS
云计算(Cloud Computing)被业界看作继大型计算机.个人计算机.互联网之后的第四次IT产业革命,正日益成为未来互联网与移动技术相结合的一种新兴计算模式.云计算提供了IT基础设施和平台服务的 ...
- The 3rd tip of DB QueryAnalyzer
The 3rd tip of DB Query Analyzer Ma Genfeng (Guangdong Unitoll Services incorporated, Guangzhou 510 ...
- 面试题之C# 内存管理与垃圾回收
面试题之C# 内存管理与垃圾回收 你说说C# 的内存管理是怎么样的 这句话我记了一个多礼拜了, 自从上次东北师大面试之后, 具体请看<随便扯扯东北师大的面试>. 国庆闲着没事, 就大概了解 ...
- app ionic1 微信 微博 分享功能的实现
微信分享 1.登录微信开放平台注册账户 2.创建一个移动应用 (app) 审核过后会有一个appid 之后安装插件的时候会用到 3.在这个应用上面填写 包名 和 签名 就可以了 包名和签名的 ...
- Android流媒体开发之路二:NDK开发Android端RTMP直播推流程序
NDK开发Android端RTMP直播推流程序 经过一番折腾,成功把RTMP直播推流代码,通过NDK交叉编译的方式,移植到了Android下,从而实现了Android端采集摄像头和麦克缝数据,然后进行 ...
- spiral matrix 螺旋矩阵
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...