首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JDK7,mvn-3.2.2 -maven-执行器-插件- RequireJavaVersion失败

JDK7,mvn-3.2.2 -maven-执行器-插件- RequireJavaVersion失败
EN

Stack Overflow用户
提问于 2014-07-10 15:30:55
回答 1查看 7.2K关注 0票数 2

我正在使用JDK 1.7.0_60maven-3.2.2。当我在我的项目mvn clean install上运行new-project时,我会得到以下错误-

代码语言:javascript
复制
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ new-project ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (default) @ new-project ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.7.0-60 is not in the allowed range [1.5,1.6,1.7.0-60).
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.621 s
[INFO] Finished at: 2014-07-10T20:37:32+05:30
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (default) on project new-project: Some Enforcer rules have failed.
Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

以下是我的pom.xml的一部分,因为我不能分享完整的内容-

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <showDeprecation>true</showDeprecation>
        <source>1.7.0-60</source>
        <target>1.7.0-60</target>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
        <classpathContainers>
            <classpathContainer>
    org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5
            </classpathContainer>
        </classpathContainers>
        <additionalConfig>
            <file>
                <name>
                    .settings/org.eclipse.core.resources.prefs
                </name>
                <content>
    eclipse.preferences.version=1${line.separator}encoding/&lt;project&gt;=UTF-8${line.separator}
                </content>
            </file>
        </additionalConfig>
        <downloadSources>true</downloadSources>
    </configuration>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <configuration>
        <rules>
            <requireJavaVersion>
                <version>[1.5,1.6,1.7.0-60)</version>
            </requireJavaVersion>
            <requireMavenVersion>
                <version>[3.2.2,)</version>
            </requireMavenVersion>
        </rules>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>enforce</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <configuration>
        <sourcepath>
            ${project.basedir}/src/main/javadoc;${project.basedir}/src/main/java
        </sourcepath>
        <charset>UTF-8</charset>
        <docencoding>UTF-8</docencoding>
        <docfilessubdirs>true</docfilessubdirs>
        <links>
            <link>
                http://docs.oracle.com/javase/7/docs/api/
            </link>
        </links>
        <source>1.7.0-60</source>
        <show>protected</show>
    </configuration>
    <reportSets>
        <reportSet>
            <reports>
                <report>javadoc</report>
            </reports>
        </reportSet>
    </reportSets>
</plugin>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-10 15:56:16

如果要在接受的范围中包含1.7.0-30版本,则在声明范围时必须使用方括号。您可以省略1.6版本,因为它包含在范围中:

代码语言:javascript
复制
<requireJavaVersion>
    <version>[1.5,1.7.0-60]</version>
</requireJavaVersion>
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24680585

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档