根据我在springboot多模块项目中的项目结构

<packaging> pom </packaging>

serverchild <packaging> jar </packaging>

angularchild <packaging> jar </packaging>

我想从此项目结构创建EAR文件,以将其部署在Websphere上。
在某些教程中,提到添加另一个孩子说

parent_ear <packaging>耳朵</packaging>

并添加serverchild和angularchild的依赖关系。但是,然后我无法执行Maven更新。

还有其他方法吗?

最佳答案

您可以选择创建一个包含两个模块的父级项目POM文件。该结构的典型示例如下所示:

父POM

<?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.example</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Parent</name>
<description>Application</description>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<modules>
    <module>client</module>
    <module>server</module>
</modules>

</project>


*模块POM

<?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>

<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>example-module</artifactId>
<packaging>jar<packaging>

<name>modules</name>
<description>Application</description>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>
</project>


带有模块的EAR POM

<?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>
<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>example-ear</artifactId>
<packaging>ear<packaging>

<dependencies>
    <dependency>
      <groupId>com.example</groupId>
      <artifactId>example-module</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>

<build>
   <plugins>
     <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.10.1</version>
        <configuration>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>



如果您有任何疑问,请告诉我

08-18 08:34