简体   繁体   English

在使用Maven构建项目时遇到问题

[英]Having problems building a project with Maven

I've just started work on a project that uses maven. 我刚刚开始使用Maven的项目。 However, when I try to build the project I get the following error: 但是,当我尝试构建项目时,出现以下错误:

MyClass.java:[7,2] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
@Override

I have the latest JRE installed on my machine, and I have tried editing the pom.xml file to fix this but I have had no luck. 我在计算机上安装了最新的JRE,并且尝试编辑pom.xml文件来解决此问题,但是我没有运气。 I've also tried searching Google but I've come up with near nothing. 我也曾尝试搜索Google,但几乎没有提出任何建议。

Does anyone know how I can configure the project to use the latest JRE? 有谁知道我如何配置项目以使用最新的JRE? Or another solution if this isn't the problem. 或者,如果这不是问题,请使用其他解决方案。

Thanks in advance. 提前致谢。

(Also, I have never used Maven before so forgive me if anything I say sounds stupid) (此外,我以前从未使用过Maven,所以如果我说的话听起来很愚蠢,请原谅我)

EDIT: I am using maven from the terminal in the latest Ubuntu release 编辑:我正在最新的Ubuntu版本中从终端使用maven

Open your pom.xml and search for plug-in with artifact ID maven-compiler-plugin. 打开pom.xml并搜索带有工件ID maven-compiler-plugin的插件。 Check tag . 检查标签。 It seems it is 1.3 in your case. 您的情况似乎是1.3。 Change it to 1.5 (unless you really have to compile your code for JVM 1.3. In this case you should remove the stuff that is not compatible with this old version - eg annotations.) 将其更改为1.5(除非您真的必须为JVM 1.3编译代码。在这种情况下,您应该删除与该旧版本不兼容的内容-例如注释。)

I suspect that you have configured an older version of the JRE within your pom.xml. 我怀疑您在pom.xml中配置了旧版本的JRE。

Does your pom.xml contain something like this? 您的pom.xml是否包含这样的内容?

    <properties>
            <java.version>1.6</java.version>
    </properties>
    <build>
            <plugins>
                    <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-compiler-plugin</artifactId>
                            <configuration>
                                    <source>${java.version}</source>
                                    <target>${java.version}</target>
                            </configuration>
                    </plugin>
            </plugins>
    </build>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM