0

My application is packaged as WAR. I am trying to write the pom environment and timestamp to application.properties file. I tried using resource filtering but it didn't work. Looking forward for your help. Below are pom.xml and application.properties file.

application.properties

 version.environment=${pom.env}
 version.number=${pom.version}
 version.buildnumber=${timestamp}

pom.xml(with resource fitering)

 <?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>

        <groupId>com.infoconnect.com</groupId>
        <artifactId>ic-api</artifactId>
        <version>2.0</version>
        <packaging>war</packaging>

        <!-- Inherit defaults from Spring Boot -->
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.4.0.RELEASE</version>
        </parent>

        <properties>
            <build.timestamp>${maven.build.timestamp}</build.timestamp>

            <maven.build.timestamp.format>yyyy-MM-dd-HH-mm</maven.build.timestamp.format>

            <servlet-api.version>3.0.1</servlet-api.version>
        </properties>

        <!-- Add typical dependencies for a web application -->
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
        </dependencies>

        <!-- Package as an executable JAR -->
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </build>

        <!-- Allow access to Spring milestones and snapshots -->
        <!-- (you don't need this if you are using anything after 0.5.0.M2) -->

    </project>
Rakesh Gourineni
  • 1,361
  • 5
  • 16
  • 30

0 Answers0