[英]Why does eclipse not recognize Java nature of a multimodule maven project if name template is added to it?
I've a springboot project which is organized as multiple modules.我有一个组织为多个模块的 springboot 项目。 I'm using Eclipse 2019-06 (version 4.12) with jdk 1.8 update 131 and apache maven 3.3.9 version.我正在使用 Eclipse 2019-06(版本 4.12)和 jdk 1.8 update 131 和 apache maven 3.3.9 版本。
While importing the project using Maven -> Existing maven projects -> select all project and module level poms->click on finish button , it does the import successfully.使用Maven导入项目时-> Existing maven projects -> select all project and module level poms->click on finish button ,它成功导入。
I can view the child modules as separate projects that can be individually run by right clicking on them to project workspace.我可以将子模块视为单独的项目,可以通过右键单击它们到项目工作区来单独运行。 JUnit tests successfully run using right click -> Run As -> JUnit test.使用右键单击 -> 运行方式 -> JUnit 测试成功运行JUnit 测试。
But if i include a name template while importing the project, the child modules are not recognized even though I select all the child poms also while importing.但是,如果我在导入项目时包含一个名称模板,即使我在导入时也选择了所有子 poms,子模块也无法识别。
Java files show empty J which indicates that it doesn't recognize the Java nature. Java 文件显示空 J,这表明它不识别 Java 性质。 Because of this, I am unable to run JUnit tests and ctrl+click to navigate to a method or class is also not working.因此,我无法运行JUnit测试并且ctrl+click导航到方法或类也不起作用。
In both cases, the contents of .project remain the same:在这两种情况下, .project 的内容保持不变:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>my-springboot-app</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
I tried the following steps as suggested in other stackoverflow threads:我按照其他 stackoverflow 线程中的建议尝试了以下步骤:
Note that eclipse builds the project while importing it when I do not import the project specifying a name template for it but not otherwise.请注意,当我不导入项目时,eclipse 会在导入项目时构建项目,为其指定名称模板,否则不会。
It would be nice if someone could let me know if that is a problem with m2e plugin itself and that whether I should use another plugin instead.如果有人能让我知道这是否是m2e 插件本身的问题,以及我是否应该使用其他插件,那就太好了。
Eclipse 4.12 comes with m2e pre-installed with it. Eclipse 4.12预装了m2e 。 I thought of using a name template instead of switching workspaces which could take time so that 2-3 flavours of my code can be seen in the same eclipse workspace .我想过使用名称模板而不是切换工作区,这可能需要时间,以便可以在同一个Eclipse 工作区中看到 2-3 种风格的代码。
The problem was with custom name being used as name template.问题在于自定义名称被用作名称模板。 When I use any of the available options like [groupid].[artifactid]-version or just the [artifactid]-version, m2e successfully imports the project.当我使用任何可用选项(如 [groupid].[artifactid]-version 或仅使用 [artifactid]-version)时,m2e 成功导入项目。 I saw some errors in the earlier project with respect to import class resolution but they went away when i closed unrelated projects in workspace.我在较早的项目中看到了一些关于导入类解析的错误,但是当我关闭工作区中不相关的项目时它们就消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.