我在m2eclipse中构建错误,但在命令行上没有使用maven2 - 我的m2eclipse配置错误? [英] I have build errors with m2eclipse but not with maven2 on the command line - is my m2eclipse misconfigured?

查看:164
本文介绍了我在m2eclipse中构建错误,但在命令行上没有使用maven2 - 我的m2eclipse配置错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我导入的项目如下:

 导入 - > 
Maven->
现有的Maven项目 - >
导入Maven项目 - >
- 选择根目录
- 选择pom文件
- 单击完成

为了确保m2eclipse正在构建项目,我删除了目标目录,并确保它是由m2eclipse重新创建的。但是与maven的命令行版本完全不同,m2eclipse在源代码中留下了大量的构建错误。



是否可能我没有正确配置m2eclipse?如何查看?



这是项目的github链接我正在尝试构建。我在此行。它说方法createNewToken必须覆盖超类方法。

解决方案

更新:中所述的相同必须覆盖超类方法将项目导入到Eclipse中后会出现错误,这里是接受的答案:


Eclipse是默认为Java 1.5,并且您有实现接口方法的类(在Java 1.6中可以使用@Override进行注释,但在Java 1.5中只能应用于覆盖超类方法的方法)。




将编译器级别更改为Java 1.6会使问题消失。为此,请修改编译器插件配置:

 < plugin> 
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.1< / version>
< configuration>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>
< / plugin>

并更新项目配置(右键单击 strong> Maven V更新项目配置)解决了Eclipse下的问题。



或者坚持使用1.5,但删除有问题的@Override注释。



我不知道泰勒如何使用Java 1.5编译器级别。我的猜测是,该项目不会在JDK 5的命令行上建立。







但是与maven的命令行版本完全不同,m2eclipse在源代码中留下了大量构建错误。



$ b $很难说发生的是什么,没有看到那些错误(他们真的是错误?)。请提供一些痕迹。


是否可以正确配置m2eclipse?我如何检查这个?


一个区别是m2eclipse默认使用Maven 3的嵌入版本,这可能是不一样的版本你在命令行上使用。您可以通过 Window V Preferences V Maven V安装进行更改(并添加自己的安装):





但是,我建议在Eclipse下使用相同的版本,而不是命令行,这很可能不是问题的根本原因,Maven 2构建应该在Maven 3上运行没有问题。


I installed m2eclipse to build a java project in Eclipse.

I imported the project as follows:

Import->
Maven->
Existing Maven Projects->
Import Maven Projects->
- Select root directory
- Select pom file
- Click Finish

To be sure m2eclipse was actually building the project, I deleted the target directory and made sure it was re-created by m2eclipse and it was. But unlike with the command-line version of maven which built everything perfectly, m2eclipse leaves a large number of build errors in the source code.

Is it possible that I did not configure m2eclipse properly? How would I check this?

This is a github link to the project I'm trying to build. I'm getting the @Override build errors at this line. It says "The method createNewToken must override a superclass method".

解决方案

Update: The problem is the same as the one described in ‘Must Override a Superclass Method’ Errors after importing a project into Eclipse and here is what the accepted answer says:

Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be applied to methods overriding a superclass method).

Changing the compiler level to Java 1.6 would make the problem go away. To do so, modify the compiler plugin configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>

And update the project configuration (right-click on the project then Maven V Update Project Configuration) does solve the problem under Eclipse.

Or stick with 1.5 but remove the problematic @Override annotations.

I don't know how Taylor got things working with a Java 1.5 compiler level. And my guess is that the project wouldn't build on the command line with a JDK 5.


But unlike with the command-line version of maven which built everything perfectly, m2eclipse leaves a large number of build errors in the source code.

Hard to say what is happening exactly without seeing those "errors" (are them really errors?). Please provide some traces.

Is it possible that I did not configure m2eclipse properly? How would I check this?

One difference is that m2eclipse uses by default a embedded version of Maven 3 which is probably not the same version that you use on the command line. You can change that through Window V Preferences V Maven V Installation (and add your own installation):

But while I would recommend to use the same version under Eclipse than on the command line, this is very likely not the root cause of the problem, Maven 2 builds should run on Maven 3 without problems.

这篇关于我在m2eclipse中构建错误,但在命令行上没有使用maven2 - 我的m2eclipse配置错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆