我在eclipse中使用了m2eclipse插件.为什么导入的包仍然不能被eclipse解决? [英] I used m2eclipse plugins in eclipse.why the imported package still cannot be resolved by eclipse?

查看:433
本文介绍了我在eclipse中使用了m2eclipse插件.为什么导入的包仍然不能被eclipse解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个mvn项目,并在eclipse中调试该项目,我将该项目导入了eclipse中,但是有些导入的软件包无法被eclipse解决是很可惜的.并运行"mvn eclipse:eclipse"将项目转换为类似eclipse的项目,因此所有软件包都将自动导入eclipse构建路径.是的,我这样做.蚀构建路径就是这样

I get a mvn project , and to debug this project in eclipse,I imported the project into eclipse.But it's a pitty that some imported packages cannot be resolved by eclipse.Othes tell me that I should install m2eclipse plugin for eclipse, and run ""mvn eclipse:eclipse" to convert the project as a eclipse-like" project ,thus all packages will imported to eclipse build path automatically. Yes , I do so. And the eclipse build path is just like this

:

但是,Eclipse仍然无法解决某些导入问题,这是非常奇怪的.

But it is extremely strange that eclipse still cannot resolve some import .

任何人都可以告诉我发生了什么事?从构建路径中,我可以看到eclipse已经为我导入了所需的jar文件.但是似乎构建路径没有生效.

Any body can tell me what happened? From the build path ,I can see that eclipse have already imported the needed jar file for me.But it seems that the build path didn't take effect.

推荐答案

首先,您没有使用m2e插件;尽管可能已安装,但尚未为此项目激活它:

First of all, you're not using the m2e plugin; while it may be installed, it's not activated for this project:

  1. 项目图标上没有小"M"
  2. 类路径不包含条目org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER

据我所知,由于未定义变量M2_REPO,Eclipse无法解析依赖关系(如果可以的话,您会在上方图像中看到JAR的绝对路径符号路径).

From what I can see, Eclipse can't resolve the dependencies since the variable M2_REPO isn't defined (if it could, you would see the absolute path to the JARs in the upper image after the symbolic path).

要解决此问题,请转到首选项"并搜索"Classpath Variables".在其中添加M2_REPO并使用正确的路径(默认为$HOME/.m2/repository).

To fix this, go to Preferences and search for "Classpath Variables". Add M2_REPO there with the correct path (default is $HOME/.m2/repository).

如果已经存在,请确保路径正确.

If it already exists, make sure the path is correct.

或者,右键单击项目,然后在"Configuration"下选择"Convert to Maven Project".

Alternatively, right click on project and select "Convert to Maven Project" under "Configuration".

这篇关于我在eclipse中使用了m2eclipse插件.为什么导入的包仍然不能被eclipse解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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