This is the build configuration of my project in pom.xml, When I pack the project, the property files already changed with the selected profile properties, but when I run the project using maven-boot-plugin:run in Intellij IDEA
, the property files changed to old style and the database connection raises exception. for example the normal application.properties has the below key :
spring.datasource.url=${datasourceUrl}
and after packing the project it is :
spring.datasource.url=url1
but after running spring boot plugin the property files changed to the first style.
<profiles>
<profile>
<id>Live</id>
<properties>
<datasourceUrl>url1</datasourceUrl>
</properties>
</profile>
<profile>
<id>Test</id>
<properties>
<datasourceUrl>url2</datasourceUrl>
</properties>
</profile>
</profiles>
<build>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<id>run</id>
<phase>package</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repack</id>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
mywar
<type>war</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes/static/</outputDirectory>
<includes>**/*</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>