Maven Resource Filter not working - due to spring loading

In the maven project, I am trying to replace some tokens using maven resource filtering, but this does not work. I have several other projects that work, but do not work in this one project, are not sure what is wrong.

Property files are located in the /src/main/resources/my.properties directory

I have tried different maven commands as below, but not working.

mvn clean install mvn clean install resources:resources 

my.properties

 ### Spring boot properties jdbc.url=${jdbc.url} ldap.domain=${ldap_domain} ldap.url=${ldap_url} 

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>com.jai</groupId> <artifactId>client</artifactId> <version>0.0.6-SNAPSHOT</version> <name>client</name> <description>client web application</description> <packaging>war</packaging> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.2.RELEASE</version> <relativePath /> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-ldap</artifactId> </dependency> </dependencies> <build> <finalName>client</finalName> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <execution> <id>exec-bower-install</id> <phase>generate-sources</phase> <configuration> <executable>bower</executable> <arguments> <argument>install</argument> </arguments> </configuration> <goals> <goal>exec</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <profiles> <!-- localhost environment --> <profile> <id>local</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <ldap_domain>mydomain.local</ldap_domain> <ldap_url>ldap://server:389</ldap_url> <jdbc.url>testttttttttttttttttttttt</jdbc.url> </properties> </profile> </profiles> </project> 

Update: -

I realized that this problem is caused by the spring boot dependency. If I comment on the <parent> section and other spring boot dependencies, then it works fine and can replace the token. But still not sure how to fix this while maintaining spring loading.

+47
java spring-boot maven
Apr 08 '16 at 13:36
source share
1 answer

Finally found the answer from the link in my comments. Since this is a spring boot application ... special case ... notations should be

 @xxxxx@ instead of ${xxxxx} 

So my properties file will be below

 ### Spring boot properties jdbc.url=@jdbc.url@ ldap.domain=@ldap_domain@ ldap.url=@ldap_url@ 
+100
Apr 08 '16 at 15:18
source share



All Articles