[英]Eclipse settings for maven modules
I cloned the maven project to my local disk.我将 Maven 项目克隆到我的本地磁盘。 The project has 3 modules as well as a parent project.
该项目有 3 个模块以及一个父项目。 i marked the 3 modules with the 3 colors-- the 4th, blue color is the project itself.
我用 3 种颜色标记了 3 个模块——第四个,蓝色是项目本身。
The project is running all fine on maven both on Eclipse and on command line.该项目在 Eclipse 和命令行上的 Maven 上运行良好。 When i do a
mvn install
on Eclipse, the project is built and all the tests are run successfully -- i see the good old BUILD SUCCESS
report of maven on Eclipse console.当我在 Eclipse 上执行
mvn install
时,项目已构建并且所有测试都成功运行——我在 Eclipse 控制台上看到了 maven 的旧版BUILD SUCCESS
报告。
The problem is -- the modules are all messed up.问题是——模块都搞砸了。 (this "messed up" is the best way i can put it for now.) Eclipse doesn't recognize the dependencies between modules and gives checked errors to some of the code that use outside dependencies.
(这个“搞砸了”是我现在可以说的最好的方式。)Eclipse 无法识别模块之间的依赖关系,并为一些使用外部依赖关系的代码提供检查错误。
At one place-- lombok @Getter
is used in one class.在一个地方
@Getter
用于一个班级。 import lombok.Getter;
is seen by the compiler-- no checked error to that.被编译器看到——没有检查错误。 but eclipse doesn't recognize the getter declaration of lombok, say
getField()
for the field field
.但是 eclipse 无法识别 lombok 的 getter 声明,比如字段
field
getField()
。 i know this because : a) in the class itself-- gives a warning that .. the private field field
isn't used.我知道这一点是因为:a) 在类本身中 - 发出警告,提示.. 未使用私有字段
field
。 b) gives a checked error to getField()
a reference from another class. b) 向
getField()
提供来自另一个类的引用的已检查错误。 Thought this might be an interesting example to how the dependencies are "working".认为这可能是一个关于依赖项如何“工作”的有趣示例。 i'm guessing one dependency that lombok is using is intercepted somewhere along the way to give this inconsistency.
我猜 lombok 正在使用的一个依赖项在途中的某个地方被拦截,以产生这种不一致。
Following is the project root directory structure on disk.以下是磁盘上的项目根目录结构。 (the 3 colors are the 3 modules, have to hide the names for confidentiality):
(3种颜色是3个模块,为了保密,必须隐藏名称):
the 3 modules are defined in the pom.xml as follows:这 3 个模块在 pom.xml 中定义如下:
i see the following in Eclipse project explorer:我在 Eclipse 项目资源管理器中看到以下内容:
so in the Project explorer, the 2 modules/tests (green & yellow) that have java dir, ie src/main/java
appear twice.所以在项目资源管理器中,具有 java 目录的 2 个模块/测试(绿色和黄色),即
src/main/java
出现两次。 the orange module has only src/main/resources
and no src/main/java
.橙色模块只有
src/main/resources
,没有src/main/java
。
In the second occurrences of the modules in the project explorer (the image above), there are no dependencies of any kind, not even Java itself and hence all those red dots all around (compiler errors).在项目资源管理器(上图)中第二次出现模块时,没有任何类型的依赖项,甚至没有 Java 本身,因此周围都是红点(编译器错误)。 The first occurrences of modules have
Referenced Libraries
and no Maven Dependencies
:第一次出现的模块有
Referenced Libraries
并且没有Maven Dependencies
:
How to fix this project so that i can code and run in Eclipse?如何修复这个项目,以便我可以在 Eclipse 中编码和运行? Just to pin down-- project configuration is all fine and it runs successfully on maven.
只是为了确定 - 项目配置一切正常,并且在 maven 上成功运行。 the problem is Eclipse's own settings on it.
问题是 Eclipse 自己的设置。
so far i tried the following:到目前为止,我尝试了以下操作:
File > Import > Maven > Existing Maven Projects
File > Import > Maven > Existing Maven Projects
mvn eclipse:eclipse
on its pom.xmlmvn eclipse:eclipse
Wasn't even seeing the Build path
before these.在这些之前甚至没有看到
Build path
。
i'd appreciate the help-- wore me out.我很感激你的帮助——让我筋疲力尽。
everyone else on the project is IntelliJ developer-- no workspace to compare with.项目中的其他人都是 IntelliJ 开发人员——没有工作空间可以比较。
i've seen Importing Maven project into Eclipse and some other useful discussions.我已经看到将 Maven 项目导入 Eclipse以及其他一些有用的讨论。
i'm not sure whether i should post .project, .settings and some other file contents also.我不确定我是否也应该发布 .project、.settings 和其他一些文件内容。 will do if necessary.
必要时会做。
TIA. TIA。
Make sure to not only import the parent pom.xml
, but also the Maven modules as projects into Eclipse .确保不仅将父
pom.xml
导入,还将 Maven 模块作为项目导入到 Eclipse 中。 To do this in one go, use要一次性完成此操作,请使用
Make also sure Lombok has been installed into Eclipse , otherwise Eclipse's own incremental compiler would not generate eg getter and setter methods that are defined by Lombok annotations.还要确保Lombok 已安装到 Eclipse 中,否则 Eclipse 自己的增量编译器将不会生成例如由 Lombok 注释定义的 getter 和 setter 方法。 See the Lombok documentation of how to install Lombok into Eclipse .
请参阅有关如何将 Lombok 安装到 Eclipse 中的Lombok 文档。 If you have installed Lombok after importing the projects, it might be that you need to do a Project > Clean... or close and reopen again the projects (via the right-click menu).
如果您在导入项目后安装了 Lombok,则可能需要执行Project > Clean...或关闭并重新打开项目(通过右键单击菜单)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.