Spring boot exclude properties file and provide it to jar on execution

Viewed 17422

I have multiple set of properties file smtp, db, common settings under src/main/resources directory and my project is maven project jar packaging. I want to exclude all these properties file from jar building and place all these properties files to target/conf folder. Now i want to provide all these configuration file to my jar when i execute application jar. How to achieve this? I have done couple of things in pom.xml file to exclude all these properties and now unable to provide them to the generated jar. This is for exclude src/main/resources content

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <excludes>
            <exclude>*.properties</exclude>
        </excludes>
        <filtering>false</filtering>
    </resource>
</resources>

Spring boot Plugin configuration

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <executable>true</executable>
    </configuration>
</plugin>

Maven resources plugin to place all the resources files under target/conf folder

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>target/conf</outputDirectory>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>
1 Answers
Related