2

This is my pom.xml in a simple project:

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <relativePath/>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>test</name>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <build>
        <filters>
            <filter>src/main/resources/filters/test.filter</filter>
        </filters>
        <resources>
            <resource>
                <directory>src/main/resources/export</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

and this is my resources

src/main/resources/export/app.properties

Hello ${test_prop}

src/main/resources/filters/test.filter

test_prop = World

When I run mvn resources:resources or mvn clean package the result in target folder is the original app.properties (no filtering). Does anyone know why it is not filtering?

dgolive
  • 425
  • 3
  • 8

1 Answers1

2

From Spring documentation: If you use the spring-boot-starter-parent, you can then refer to your Maven 'project properties' with @..@ placeholders, as shown in the following example:

app.encoding=@project.build.sourceEncoding@
app.java.version=@java.version@

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html

dgolive
  • 425
  • 3
  • 8