0

I am trying to use maven-resources-plugin to copy properties from maven profiles onto the application properties file but with no luck, and i cant find what i am missing for it to work

I have in my pom.xml:

<profiles>
    <profile>
        <id>development</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <profile.Amazon.S3.accessKeyId>123</profile.Amazon.S3.accessKeyId>
            <profile.Amazon.S3.secretAccessKey>123</profile.Amazon.S3.secretAccessKey>
        </properties>
    </profile>
    <profile>
        <id>production</id>
        <properties>
            <profile.Amazon.S3.accessKeyId>456</profile.Amazon.S3.accessKeyId>
            <profile.Amazon.S3.secretAccessKey>4567</profile.Amazon.S3.secretAccessKey>
        </properties>
    </profile>
</profiles>

AND:

    <build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

my properties file:

Amazon.S3.accessKeyId=${profile.Amazon.S3.accessKeyId} Amazon.S3.secretAccessKey=${profile.Amazon.S3.secretAccessKey}

when running the application (does not matter if i specify a profile or not) i always get an error from spring on this line:

private @Value("${Amazon.S3.accessKeyId}") String S3_ACCESS_KEY;

 Could not resolve placeholder 'profile.Amazon.S3.accessKeyId' in string value "${profile.Amazon.S3.accessKeyId}"
2
  • First, is it a Maven problem, or a Spring configuration problem? Check what the properties file contains in target/classes. If the property has been replaced, it's not a Maven problem, but a SPring config problem.
    – JB Nizet
    Aug 24, 2014 at 13:14
  • its not been replaced its left with the "${profile.Amazon.S3.accessKeyId} "
    – Gleeb
    Aug 24, 2014 at 13:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.