parent POM 的无效包装必须是 "pom" 但 "war"
Invalid packaging for parent POM must be "pom" but is "war"
任何人都可以建议我一个解决方案,但有以下例外。我要创建一个 multi-module 项目。 (War, 耳朵)
pom.xml (war)
<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>lu.pgd</groupId>
<artifactId>WebBusiness</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>WebBusiness-war</artifactId>
<packaging>war</packaging>
<name>Web Business</name>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<slf4j.version>1.7.5</slf4j.version>
</properties>
<build>
<finalName>webBusiness</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml(耳朵)
<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>lu.pgd</groupId>
<artifactId>WebBusiness</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>spdv-ear</artifactId>
<packaging>ear</packaging>
<name>Project EAR</name>
<dependencies>
<dependency>
<groupId>lu.pgd</groupId>
<artifactId>WebBusiness-war</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<finalName>WebBusiness</finalName>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<applicationId>WebBusiness</applicationId>
<displayName>SPDV (${project.version})</displayName>
<modules>
<webModule>
<groupId>lu.pgd</groupId>
<artifactId>WebBusiness-war</artifactId>
<contextRoot>/WebBusiness</contextRoot>
<moduleId>war</moduleId>
</webModule>
</modules>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml (parent)
<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>lu.pgd</groupId>
<artifactId>WebBusiness</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Parent Project</name>
<modules>
<module>../SPDV_EAR</module>
<module>../WebBusiness</module>
</modules>
<packaging>pom</packaging>
</project>
当我尝试 运行 Maven Project Parent (Clean+Install) 时,我得到了如下错误:
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
@
[ERROR] The build could not read 2 projects -> [Help 1]
[ERROR]
[ERROR] The project lu.pgd:ccpd-ear:0.0.1-SNAPSHOT (C:\Users\x279\workspace\SPDV_EAR\pom.xml) has 1 error
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
[ERROR] The project lu.pgd:WebBusiness-war:0.0.1-SNAPSHOT (C:\Users\x279\workspace\WebBusiness\pom.xml) has 1 error
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
有人可以帮我了解这里出了什么问题吗?
将您的模块 SPDV_EAR 和 WebBusiness 复制到父项目文件夹 (ccpd) 中。然后将父pom中的modules标签改成:
<modules>
<module>SPDV_EAR</module>
<module>WebBusiness</module>
</modules>
也在你的父 pom 更改
<artifactId>WebBusiness</artifactId>
到
<artifactId>ccpd</artifactId>
在您的war(WebBusiness)中:
<parent>
<groupId>lu.pgd</groupId>
<artifactId>ccpd</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>WebBusiness</artifactId>
在你耳边:
<parent>
<groupId>lu.pgd</groupId>
<artifactId>ccpd</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>SPDV_EAR</artifactId>
因此您的文件夹名称与您的项目名称相符。
通常多模块项目的文件夹结构是这样的:
- parent-project-folder
- pom.xml (parent-project)
- submodule-project-folder
- pom.xml (submodule-project)
- another-submodule-project-folder
- pom.xml (another-submodule-project)
那么你的父定义就可以了,但是你的子模块旁边有父项目,所以你需要多配置一点。
尝试将 relativePath 添加到您的父规范中:
<parent>
<groupId>...
...
<relativePath>path/to/your/parent/pom.xml</relativePath>
</parent>
任何人都可以建议我一个解决方案,但有以下例外。我要创建一个 multi-module 项目。 (War, 耳朵)
pom.xml (war)
<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>lu.pgd</groupId>
<artifactId>WebBusiness</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>WebBusiness-war</artifactId>
<packaging>war</packaging>
<name>Web Business</name>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<slf4j.version>1.7.5</slf4j.version>
</properties>
<build>
<finalName>webBusiness</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml(耳朵)
<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>lu.pgd</groupId>
<artifactId>WebBusiness</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>spdv-ear</artifactId>
<packaging>ear</packaging>
<name>Project EAR</name>
<dependencies>
<dependency>
<groupId>lu.pgd</groupId>
<artifactId>WebBusiness-war</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<finalName>WebBusiness</finalName>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<applicationId>WebBusiness</applicationId>
<displayName>SPDV (${project.version})</displayName>
<modules>
<webModule>
<groupId>lu.pgd</groupId>
<artifactId>WebBusiness-war</artifactId>
<contextRoot>/WebBusiness</contextRoot>
<moduleId>war</moduleId>
</webModule>
</modules>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml (parent)
<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>lu.pgd</groupId>
<artifactId>WebBusiness</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Parent Project</name>
<modules>
<module>../SPDV_EAR</module>
<module>../WebBusiness</module>
</modules>
<packaging>pom</packaging>
</project>
当我尝试 运行 Maven Project Parent (Clean+Install) 时,我得到了如下错误:
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
@
[ERROR] The build could not read 2 projects -> [Help 1]
[ERROR]
[ERROR] The project lu.pgd:ccpd-ear:0.0.1-SNAPSHOT (C:\Users\x279\workspace\SPDV_EAR\pom.xml) has 1 error
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
[ERROR] The project lu.pgd:WebBusiness-war:0.0.1-SNAPSHOT (C:\Users\x279\workspace\WebBusiness\pom.xml) has 1 error
[ERROR] Invalid packaging for parent POM lu.pgd:WebBusiness:0.0.1-SNAPSHOT, must be "pom" but is "war" @ lu.pgd:WebBusiness:0.0.1-SNAPSHOT, C:\dev\lu\pgd\WebBusiness[=16=].0.1-SNAPSHOT\WebBusiness-0.0.1-SNAPSHOT.pom, line 7, column 13
有人可以帮我了解这里出了什么问题吗?
将您的模块 SPDV_EAR 和 WebBusiness 复制到父项目文件夹 (ccpd) 中。然后将父pom中的modules标签改成:
<modules>
<module>SPDV_EAR</module>
<module>WebBusiness</module>
</modules>
也在你的父 pom 更改
<artifactId>WebBusiness</artifactId>
到
<artifactId>ccpd</artifactId>
在您的war(WebBusiness)中:
<parent>
<groupId>lu.pgd</groupId>
<artifactId>ccpd</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>WebBusiness</artifactId>
在你耳边:
<parent>
<groupId>lu.pgd</groupId>
<artifactId>ccpd</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>SPDV_EAR</artifactId>
因此您的文件夹名称与您的项目名称相符。
通常多模块项目的文件夹结构是这样的:
- parent-project-folder
- pom.xml (parent-project)
- submodule-project-folder
- pom.xml (submodule-project)
- another-submodule-project-folder
- pom.xml (another-submodule-project)
那么你的父定义就可以了,但是你的子模块旁边有父项目,所以你需要多配置一点。
尝试将 relativePath 添加到您的父规范中:
<parent>
<groupId>...
...
<relativePath>path/to/your/parent/pom.xml</relativePath>
</parent>