简体   繁体   English

无法将Java Project性质添加到嵌套的m2Eclipse项目

[英]Can't add Java Project nature to nested m2Eclipse project

I have a nested m2Eclipse project in Indigo. 我在Indigo中有一个嵌套的m2Eclipse项目。 The parent project contains the src folder that is used by the nested modules (see structure below). 父项目包含嵌套模块使用的src文件夹(请参见下面的结构)。

  • parent
    • src SRC
    • pom.xml 的pom.xml
    • module1 模块1
      • pom.xml 的pom.xml
    • module2 模块2
      • pom.xml 的pom.xml

Running mvn package from the Maven run configurations builds all the modules, so dependency management appears to be working. 从Maven运行配置运行mvn软件包会构建所有模块,因此依赖项管理似乎正在运行。 However, I don't have a MAVEN DEPENDENCIES folder and I can't use Java content-assistance or any other Java Project capabilities on any of the source files. 但是,我没有MAVEN DEPENDENCIES文件夹,并且不能在任何源文件上使用Java内容辅助或任何其他Java Project功能。 I tried converting the project to faceted form and adding the java facet, and that didn't work either. 我尝试将项目转换为多面形式,并添加java方面,但这也不起作用。

It is because the parent is not a java project but a pom project. 这是因为父级不是Java项目,而是pom项目。

While developing a maven project SET in eclipse using m2e, you are supposed to import all the projects into your workspace and you should do java development in module1 & module2. 在使用m2e在eclipse中开发Maven项目SET时,应该将所有项目导入到工作区中,并且应该在module1和module2中进行Java开发。

With the current way of editing java source files, you are in detached mode and none of the advanced instruments from JDT is available to you as this java file is not part of a known java model to eclipse. 使用当前的编辑Java源文件的方式,您处于分离模式,并且JDT的高级工具都不可用,因为该Java文件不是已知的Eclipse Java模型的一部分。

Try right clicking on your project and do Import... -> Existing Maven Projects. 尝试右键单击您的项目,然后执行Import ...-> Existing Maven Projects。 This way you should end up with three projects in your workspace one being the pom project and other two (supposedly both) java projects. 这样,您应该在工作空间中最终得到三个项目,一个项目是pom项目,另外两个项目(可能是两个)都应该是java项目。 Then all java development should be done in project1 and project2. 然后,所有Java开发都应在project1和project2中完成。 M2e is smart enough to create in-workspace dependencies for the java projects. M2e足够聪明,可以为java项目创建工作空间内的依赖关系。

Hasan Ceylan 哈桑·塞兰

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

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