如何在Intellij中创建Maven多模块项目?

时间:2021-01-22 20:42:34

I am using IntelliJ IDEA Community Edition 2016.1.3. I'm trying to create a maven multi module project. Project company is the parent and Project employee and Project skillset are child modules. Project employee and skillset will have packing as a WAR but Project company has packing as POM.

我正在使用IntelliJ IDEA Community Edition 2016.1.3。我正在尝试创建一个maven多模块项目。项目公司是父项目,项目员工和项目技能组合是子项目模块。项目员工和技能组件将包装为WAR,但项目公司将包装为POM。

如何在Intellij中创建Maven多模块项目? my project structure look like this (above), but i need my project structure to be like below image 如何在Intellij中创建Maven多模块项目?

我的项目结构看起来像这样(上图),但我需要我的项目结构如下图所示

and I could not create a class under employee and skillset. How can I create a multi module project without having src folder in parent (company)?

我无法在员工和技能组下创建课程。如何在父(公司)中没有src文件夹的情况下创建多模块项目?

1 个解决方案

#1


20  

Your presumption is correct, the top level project being pom packaging should have no source.

你的推测是正确的,*项目是pom包装应该没有来源。

So start by removing (just delete or move elsewhere) the src folder from the top level (and everything under it... main, java, resources, text...)

所以首先从顶层删除(只删除或移动到其他地方)src文件夹(以及它下面的所有内容... main,java,resources,text ...)

Now, looking at your modules, they look correct. You can test they are configured properly by control-clicking them from the top pom, and they should navigate to the child pom's.

现在,看看你的模块,它们看起来是正确的。您可以通过从顶部pom控制单击它们来测试它们是否正确配置,并且它们应该导航到子pom。

Lastly you want to set up a source structure under the child projects (which have war packaging). Manually create a folder structure under Employee module src\main\java, right click it and choose Mark As -> Source Root.

最后,您要在子项目(具有war包装)下设置源结构。在Employee模块src \ main \ java下手动创建一个文件夹结构,右键单击它并选择Mark As - > Source Root。

Do same for SkillSet and you're done.

为SkillSet做同样的事情就完成了。

#1


20  

Your presumption is correct, the top level project being pom packaging should have no source.

你的推测是正确的,*项目是pom包装应该没有来源。

So start by removing (just delete or move elsewhere) the src folder from the top level (and everything under it... main, java, resources, text...)

所以首先从顶层删除(只删除或移动到其他地方)src文件夹(以及它下面的所有内容... main,java,resources,text ...)

Now, looking at your modules, they look correct. You can test they are configured properly by control-clicking them from the top pom, and they should navigate to the child pom's.

现在,看看你的模块,它们看起来是正确的。您可以通过从顶部pom控制单击它们来测试它们是否正确配置,并且它们应该导航到子pom。

Lastly you want to set up a source structure under the child projects (which have war packaging). Manually create a folder structure under Employee module src\main\java, right click it and choose Mark As -> Source Root.

最后,您要在子项目(具有war包装)下设置源结构。在Employee模块src \ main \ java下手动创建一个文件夹结构,右键单击它并选择Mark As - > Source Root。

Do same for SkillSet and you're done.

为SkillSet做同样的事情就完成了。