我正在尝试pom.xml
根据文档从构建时获取一些属性.
我的目标是在我的Spring启动中注入它们,application.properties
但属性不会被替换.
这是我的代码
的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xx</groupId>
<artifactId>xx</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>xx</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
</dependencies>
<build>
<finalName>xx</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>static</directory>
<targetPath>static</targetPath>
</resource>
</resources>
</build>
Run Code Online (Sandbox Code Playgroud)
SRC \主\资源\ application.properties
application.version=${project.version}
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?这应该有用吗?
wem*_*emu 12
如果您使用的是spring boot parent pom,则默认占位符已重新配置为不与spring本身的$ {}语法冲突.
要替换maven属性,请使用@ - so @ project.version @而不是$ {project.version}.
默认情况下启用application.properties文件的过滤.
归档时间: |
|
查看次数: |
2182 次 |
最近记录: |