简体   繁体   English

IntelliJ Maven模块分组

[英]IntelliJ Maven Module grouping

I have two Maven projects "SomeSuperName1" and "SomeSuperName2" 我有两个Maven项目“ SomeSuperName1”和“ SomeSuperName2”

Both of these projects have an aggregator pom like this 这两个项目都有这样的聚合器pom

    <parent>
    <groupId>com.company.yeah</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0</version>
    <relativePath/>
    </parent>

    <groupId>com.company.yeah.myapp</groupId>
    <artifactId>parent</artifactId>
    <packaging>pom</packaging>
    <name>SomeSuperName1</name>
    <version>1.0.0-SNAPSHOT</version>

    <modules>
        <module>Child1</module>
        <module>Child2</module>
    </modules>

A module pom look like this 像这样的模块pom

  <parent>
    <groupId>com.company.yeah.myapp</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>

  <artifactId>Child1</artifactId>
  <packaging>pom</packaging>

I want IntelliJ to show both projects in the project view using the Maven name "Some Super Name", ie like 我希望IntelliJ使用Maven名称“ Some Super Name”在项目视图中显示两个项目,例如

- "SomeSuperName1"
- "SomeSuperName2"

but it constantly fails doing so. 但是这样做总是失败的。 Instead the first project is added as "Some Super Name" while the other is put in a module group structure like 相反,第一个项目被添加为“ Some Super Name”,而另一个被放入模块组结构中,例如

- "SomeSuperName1"
- parent (1) (com
   - company 
      - yeah
        - SomeSuperName2

I disabled "Create module groups for multi-module Maven projects" before importing both projects but no success. 在导入两个项目之前,我禁用了“为多模块Maven项目创建模块组”,但没有成功。

Also importing via the "Maven Projects" View or via the File->New->Module from existing Sources doesn't help. 同样,通过“ Maven项目”视图或通过File-> New-> Module从现有源导入也无济于事。 Can anyone help pls? 谁能帮忙? Problem is it's not only ugly imho but jumping to classes/methods doesn't work anymore. 问题在于,这不仅是丑陋的恕我直言,而且跳到类/方法上也行不通了。 A workaround is to rename the module from "parent (1) (com.company.yeah.SomeSuperName2)" to just SomeSuperName2 but this change is gone when restarting IntelliJ. 解决方法是将模块从“父(1)(com.company.yeah.SomeSuperName2)”重命名为SomeSuperName2,但是在重新启动IntelliJ时此更改已消失。

This has nothing to do with IntelliJ. 这与IntelliJ无关。 Your pom file (or project structure) is misconfigured. 您的pom文件(或项目结构)配置错误。

I think this will work. 我认为这会起作用。

<groupId>com.company.yeah.myapp</groupId>
<artifactId>SomeSuperName</artifactId>
<packaging>pom</packaging>
<name>Here you can put any name</name>
<version>1.0.0-SNAPSHOT</version>

<modules>
    <module>SomeSuperName1</module>
    <module>SomeSuperName2</module>
</modules>

Here you can find a nice reference. 在这里您可以找到很好的参考。

Hope that helps. 希望能有所帮助。

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

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