【发布时间】:2015-12-28 12:09:04
【问题描述】:
我希望能够为不同的环境使用不同的 log4j 配置。如果我在 tomcat (localhost:8080) 中运行项目需要使用dev.properties,如果我在产品服务器中运行项目需要使用prod.properties。我发现如here 所述,我复制了代码最佳答案,但我的 pom.xml 显示错误:
<build>
<finalName>secure-exam</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<executions>
<execution>
<id>log4j</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>output_directory</outputDirectory>
<resources>
<resource>${log4j.file}</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<log4j.file>/home/name/Workspace/spring/src/main/resources/console_log4j.properties</log4j.file>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<log4j.file>/home/name/Workspace/spring/src/main/resources/fiile_log4j.properties</log4j.file>
</properties>
</profile>
</profiles>
这是pom.xml文件中显示的错误
show cannot resolve sympol `copy-resources`
element outputDirectory is not allowed here
element resources is not allowed here
element resource is not allowed here
请告诉我如何在我的 pom.xml 中配置它?
编辑
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
【问题讨论】: