Java Intellij IDEA包括Maven已经包含的其他模块
我有一个基于Maven的两模块Intellij项目,组织如下:Java Intellij IDEA包括Maven已经包含的其他模块,java,maven,tomcat,intellij-idea,Java,Maven,Tomcat,Intellij Idea,我有一个基于Maven的两模块Intellij项目,组织如下: MyAppProject --->MyAppDomain (builds a JAR) --->MyAppWAR (builds a WAR, including the JAR above) 我可以使用Maven构建项目,结果WAR包含MyAppDomain.JAR作为依赖项: <dependency> <groupId>com.mycompany.myapp</
MyAppProject
--->MyAppDomain (builds a JAR)
--->MyAppWAR (builds a WAR, including the JAR above)
我可以使用Maven构建项目,结果WAR包含MyAppDomain.JAR作为依赖项:
<dependency>
<groupId>com.mycompany.myapp</groupId>
<artifactId>MyAppDomain</artifactId>
<version>1.0.0</version>
</dependency>
因此,IDEA似乎包括了Maven指定的JAR(MyAppDomain-1.0.0.JAR)以及它自己的JAR版本(MyAppDomain.JAR),其中包含所有相同的文件
我在Intellij IDEA中徒劳地寻找了一种关闭此行为的方法-有人知道如何停止此行为(包括共同居住项目)?我无法找到如何关闭此行为,但我找到了一种正确构建战争的解决方法
1. Select "Run -> Edit Configurations" from the menu.
2. Select your"Tomcat Server" job.
3. Click the "Deployment" tab.
4. At the bottom, where it says "Before Launch: Another Configuration," delete the "Make" option.
5. Click the "+" (plus) sign and select your Maven Build task to add it to the "Before Launch" list.
通过这样做,Intellij将使用您为创建WAR而设置的Maven构建任务,而不是使用自己的“Make”命令 我在思想上遇到了同样的问题 出现此问题是因为在启动Tomcat之前,您已经在IDEA中运行了
mvn clean package(或安装)
mvn clean包将生成Maven指定的JAR(MyAppDomain-1.0.0.JAR),但是
Tomcat将生成没有版本SPEFIED(MyAppDomain.JAR)的JAR。这就是在类路径中有两个相同JAR的问题
为了解决这个问题,在启动Tomcat之前,只要按照您的想法手动运行
mvn clean
,如果您曾经运行过mvn clean package
。我也遇到了这个问题。生成的war包含相同依赖项的两个版本(这是一个模块),这导致了问题
我必须在IntelliJ中编辑我的tomcat启动配置:
你在war文件中检查过,MyAppDomain有两个JAR,名称不同??是的,它们都在那里。请参见下面的解决方法。
1. Select "Run -> Edit Configurations" from the menu.
2. Select your"Tomcat Server" job.
3. Click the "Deployment" tab.
4. At the bottom, where it says "Before Launch: Another Configuration," delete the "Make" option.
5. Click the "+" (plus) sign and select your Maven Build task to add it to the "Before Launch" list.