Java Maven忽略了“这一点”;maven编译器插件;要求

Java Maven忽略了“这一点”;maven编译器插件;要求,java,maven,maven-compiler-plugin,maven-enforcer-plugin,Java,Maven,Maven Compiler Plugin,Maven Enforcer Plugin,我使用的是Maven 3.0.5。我对“maven编译插件”有一个问题。基本上,我有两个项目,遗留项目在Java6中,新项目在Java7中。 我现在的家很好,是: $echo$JAVA\u主页 C:\ProgramFiles(x86)\Java\jdk1.6.0\U 38 在新项目中,我将maven compile插件用于以下配置: <plugin> <groupId>org.apache.maven.plugins</groupId>

我使用的是Maven 3.0.5。我对“maven编译插件”有一个问题。基本上,我有两个项目,遗留项目在Java6中,新项目在Java7中。 我现在的家很好,是:

$echo$JAVA\u主页
C:\ProgramFiles(x86)\Java\jdk1.6.0\U 38

在新项目中,我将maven compile插件用于以下配置:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <fork>true</fork>
            <verbose>true</verbose>
            <source>1.7</source>
            <target>1.7</target>
            <executable>${JDK7}</executable>
            <compilerVersion>1.7</compilerVersion>
        </configuration>
    </plugin>

你能帮我解决这个问题吗?

好的,我想我已经找到了根本原因,可能是因为我是个白痴。Maven是使用JDK6启动的,但是这些类在Java7中编译得很好,我已经检查了输出类的次要/主要版本。正如Aurélien所提到的,enforcer插件只是用来检查Maven是否与JDK 6一起启动的。所以我取消了执行者规则。谢谢大家!

我不认为enforcer插件的这个规则是用来检查JDK兼容性的。这只是确保机器上安装JDK版本的一种方法:但如果这可以简化您的过程。实际上,您可以在每天使用版本7的同时,以JDK 6兼容模式进行编译。你可以信任maven编译器插件来处理他的CNN配置。如果你想检查是否符合某个特定的JDK,你应该看看。
    <profiles>
    <profile>
        <id>compiler</id>
        <properties>
            <JDK6>C:\Program Files (x86)\Java\jdk1.6.0_38\bin\javac</JDK6>
            <JDK7>C:\Program Files (x86)\Java\jdk1.7.0_45\bin\javac</JDK7>
        </properties>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>compiler</activeProfile>
</activeProfiles>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
    <execution>
        <id>enforce-versions</id>
        <phase>validate</phase>
        <goals>
            <goal>enforce</goal>
        </goals>
        <configuration>
            <rules>
                <requireJavaVersion>
                    <version>1.7</version>
                </requireJavaVersion>
            </rules>
        </configuration>
    </execution>
</executions>
        $ mvn compile -X
    Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 14:51:28+0100)
    Maven home: c:\Dev\apache-maven-3.0.5
    Java version: 1.6.0_38, vendor: Sun Microsystems Inc.
    Java home: c:\Program Files (x86)\Java\jdk1.6.0_38\jre
    Default locale: fr_FR, platform encoding: Cp1252
    OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
[...]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ arom-wrapper ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.6.0-38 is not in the allowed range 1.7.