1

I want to be able to use different log4j configuration for different environments. If I run project in tomcat (localhost:8080) need use dev.properties, if I run project in product server need use prod.properties. I found as described here I copied code best answer, but my pom.xml display error:

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

This is error show in pom.xml file

show cannot resolve sympol `copy-resources`
element outputDirectory is not allowed here
element resources is not allowed here
element resource is not allowed here

Please tell me how to configure this in my pom.xml?

EDIT

<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>
Community
  • 1
  • 1
Bohdan Olehovich
  • 575
  • 2
  • 13
  • 26

1 Answers1

4

You didn't copy it properly. You need to use resource plugin and not compiler plugin

    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
    <executions>
Jags
  • 799
  • 7
  • 19