Java 在部署到Tomcat之前,您是否总是需要在Maven中分别运行每个项目的pom.xml?
我有一个名为MainApp的主应用程序。此应用程序包含仪表板项目和商店项目。每当我对dashboard或store项目进行更改时,我都必须通过IntelliJ为进行更改的项目运行maven clean安装。然后我转到MainApp pom.xml的maven配置,然后通过clean install tomcat7:run-Pfront end build-U运行pom.xml来部署项目 这样做对吗?我知道这有点主观,但我在想,难道不可能从MainApp编译、构建和运行所有东西吗?我注意到,当我在MainApp中运行pom.xml时,它只是从我们的Nexus repo中获取依赖战争(商店和仪表板)(因此我猜战争不包含我的最新更改) MainApp pom.xmlJava 在部署到Tomcat之前,您是否总是需要在Maven中分别运行每个项目的pom.xml?,java,maven,Java,Maven,我有一个名为MainApp的主应用程序。此应用程序包含仪表板项目和商店项目。每当我对dashboard或store项目进行更改时,我都必须通过IntelliJ为进行更改的项目运行maven clean安装。然后我转到MainApp pom.xml的maven配置,然后通过clean install tomcat7:run-Pfront end build-U运行pom.xml来部署项目 这样做对吗?我知道这有点主观,但我在想,难道不可能从MainApp编译、构建和运行所有东西吗?我注意到,当我在
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.pab</groupId>
<artifactId>MainApp</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>store</module>
<module>dashboard</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
dependency....
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<webapps>
<webapp>
<contextPath>/store</contextPath>
<groupId>com.pab</groupId>
<artifactId>store</artifactId>
<version>${project.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
<webapp>
<contextPath>/</contextPath>
<groupId>com.pab</groupId>
<artifactId>dashboard</artifactId>
<version>${project.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
</webapps>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<uniqueVersion>true</uniqueVersion>
<url>${release.repo.url}</url>
<layout>default</layout>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<uniqueVersion>false</uniqueVersion>
<url>${snapshot.repo.url}</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
4.0.0
org.springframework.boot
spring启动程序父级
1.5.3.1发布
com.pab
主控制程序
0.0.2-快照
聚甲醛
商店
仪表板
UTF-8
UTF-8
1.8
附属国。。。。
org.apache.tomcat.maven
tomcat7 maven插件
2.2
/贮藏
com.pab
商店
${project.version}
战争
真的
/
com.pab
仪表板
${project.version}
战争
真的
释放
释放
真的
${release.repo.url}
违约
快照
快照
假的
${snapshot.repo.url}
违约
仪表板pom.xml
<modelVersion>4.0.0</modelVersion>
<artifactId>dashboard</artifactId>
<packaging>war</packaging>
<name>dashboard</name>
<parent>
<groupId>com.pab</groupId>
<artifactId>MainApp</artifactId>
<version>0.0.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<properties>
<webpack.cmd>webpack</webpack.cmd>
</properties>
<profiles>
<profile>
<id>front-end-build</id>
<build>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>dashboard</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
</plugins>
</pluginManagement>
</build>
</project>
4.0.0
仪表板
战争
仪表板
com.pab
主控制程序
0.0.2-快照
../
网页包
前端构建
execmaven插件
org.codehaus.mojo
仪表板
org.apache.tomcat.maven
tomcat7 maven插件
2.2
${project.build.directory}/${project.build.finalName}.war
存储pom.xml
<modelVersion>4.0.0</modelVersion>
<artifactId>store</artifactId>
<packaging>war</packaging>
<name>store</name>
<parent>
<groupId>com.pab</groupId>
<artifactId>MainApp</artifactId>
<version>0.0.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<profiles>
<profile>
<id>front-end-build</id>
<build>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>store</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<systemProperties>
<org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING>false
</org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING>
</systemProperties>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.4.0</version>
<configuration>
<workingDirectory>src/main/client</workingDirectory>
</configuration>
<executions>
<execution>
<id>npm</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>webpack</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
<environmentVariables>
<NODE_ENV>
production
</NODE_ENV>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
4.0.0
商店
战争
贮藏
com.pab
主控制程序
0.0.2-快照
../
前端构建
execmaven插件
org.codehaus.mojo
商店
org.springframework.boot
springbootmaven插件
org.apache.tomcat.maven
tomcat7 maven插件
2.2
假的
${project.build.directory}/${project.build.finalName}.war
execmaven插件
org.codehaus.mojo
1.4.0
src/main/client
npm
产生资源
执行官
npm
安装
网页包
产生资源
执行官
npm
跑
建造
生产
现在,经过一段时间的挣扎。我做了更多的测试。
我通过MainApp文件夹中的gitbash运行mvn clean install-Pfront end build-U,基本上是在该文件夹中执行pom.xml,该文件夹是内部模块的父pom.xml。它成功地构建了内部模块存储和仪表板。然而,我注意到的是,当我在IntelliJ:clean install-Pfront end build-U tomcat7:run中执行这个命令时。内部模块尚未构建。tomcat插件似乎试图立即部署模块,因此它试图从存储库中获取war文件。这就是问题所在
<modelVersion>4.0.0</modelVersion>
<artifactId>store</artifactId>
<packaging>war</packaging>
<name>store</name>
<parent>
<groupId>com.pab</groupId>
<artifactId>MainApp</artifactId>
<version>0.0.2-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<profiles>
<profile>
<id>front-end-build</id>
<build>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>store</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<systemProperties>
<org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING>false
</org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING>
</systemProperties>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.4.0</version>
<configuration>
<workingDirectory>src/main/client</workingDirectory>
</configuration>
<executions>
<execution>
<id>npm</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>webpack</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
<environmentVariables>
<NODE_ENV>
production
</NODE_ENV>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
<modules>
<module>store</module>
<module>dashboard</module>
</modules>