maven资源不会将任何内容复制到.properties文件

时间:2014-08-24 12:23:26

标签: java spring maven

我正在尝试使用maven-resources-plugin将maven配置文件中的属性复制到应用程序属性文件中,但没有运气,我无法找到我缺少的工作

我在我的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>

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

我的属性文件:

  

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

运行应用程序时(如果我指定一个配置文件无关紧要)我总是从这一行的春天得到一个错误:

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

 Could not resolve placeholder 'profile.Amazon.S3.accessKeyId' in string value "${profile.Amazon.S3.accessKeyId}"

0 个答案:

没有答案