将多个弹簧网站项目合并为一个可展开的战争
请帮助找到解决方案,将两个或多个spring web项目合并到一个可展开的war文件中。 我有以下项目
myproject
a. core
- src
- pom.xml
- packaging = jar
b. dao
- src
- pom.xml
- packaging = jar
- dependency on core project
c. service
- src
- pom.xml
- packaging = jar
- dependency on core and dao projects
d. salem-web
- src
- pom.xml
- packaging = war
- dependency on core, dao and service projects
到目前为止它是好的。 但我有一个新的要求,针对不同的客户,我们可以有(客户特定功能)salem-web-customer1,salem-web-customer2等。
e. service-customer1
- src
- pom.xml
- packaging = jar
- dependency on core and dao projects
f. salem-web-customer1
- src
- pom.xml
- packaging = war
- dependency on core, dao and service-customer1 projects
我们需要将salem-web和salem-web-customer1作为客户 1的一个包装,并为其他客户部署。
我已经尝试了maven覆盖和其他线程提供的解决方案,但没有任何运气。 你能否建议正确的配置(如果可能的话)将两个Web项目合并为一个。
有几种可能性,你可以这样做:
有一位家长朋友:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.greg</groupId>
<artifactId>salem</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>core</module>
<module>dao</module>
<module>service</module>
<module>service-customer1</module>
<module>salem-web</module>
<module>salem-web-customer1</module>
</modules>
</project>
例如,为每个罐子和战争项目制作具有相关性的项目
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.greg</groupId>
<artifactId>service-customer1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>service-customer1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.greg</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.greg</groupId>
<artifactId>dao</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And for a war project:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.greg</groupId>
<artifactId>salem</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>salem-web-customer1</artifactId>
<packaging>war</packaging>
<name>salem-web-customer1 Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.greg</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.greg</groupId>
<artifactId>dao</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.greg</groupId>
<artifactId>service-customer1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>salem-web-customer1</finalName>
</build>
</project>
当您构建整个项目时,您将在不同的目标文件夹中拥有所有需要的战争:
./dao/target/dao-1.0-SNAPSHOT.jar
./salem-web/target/salam-web.war
./salem-web-customer1/target/salem-web-customer1/WEB-INF/lib/core-1.0-SNAPSHOT.jar
./salem-web-customer1/target/salem-web-customer1/WEB-INF/lib/dao-1.0-SNAPSHOT.jar
./salem-web-customer1/target/salem-web-customer1/WEB-INF/lib/service-customer1-1.0-SNAPSHOT.jar
./salem-web-customer1/target/salem-web-customer1.war
./service/target/service-1.0-SNAPSHOT.jar
./service-customer1/target/service-customer1-1.0-SNAPSHOT.jar
链接地址: http://www.djcxy.com/p/95601.html
上一篇: Merge multiple spring web projects into one deployable war