java无法在pom中将打包添加为war。将xml转换为eclipse中的maven项目
我是马文的新手。我一直在用pom在eclipse中进行一个maven项目。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>com.walmart.move.nim.damage</groupId>
<artifactId>damages-external-services-parent</artifactId>
<version>1.0.36-SNAPSHOT</version>
<packaging>war</packaging> #### THIS LINE IS GIVING ERROR
</parent>
<artifactId>damages-external-services</artifactId>
<name>damages-external-services</name>
<description>Damages external services. This is the war.</description>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<springframework.version>4.3.4.RELEASE</springframework.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>7.0.62</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.walmart.move.nim.damage</groupId>
<artifactId>damages-utils</artifactId>
<version>1.0.2214</version>
<!-- <version>1.0.4-SNAPSHOT</version> -->
</dependency>
</dependencies>
由于上面提到的打包线,在eclipse中执行mvn clean安装时,出现以下错误:
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM /Users/a0m0466/workspace/damage.damages-orchestrator.dc-external-services/damages-external-services/pom.xml: Unrecognised tag: 'packaging' (position: START_TAG seen ...</version>\n <packaging>... @7:16) @ /Users/a0m0466/workspace/damage.damages-orchestrator.dc-external-services/damages-external-services/pom.xml, line 7, column 16
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.walmart.move.nim.damage:damages-external-services:1.0.36-SNAPSHOT (/Users/a0m0466/workspace/damage.damages-orchestrator.dc-external-services/damages-external-services/pom.xml) has 1 error
[ERROR] Malformed POM /Users/a0m0466/workspace/damage.damages-orchestrator.dc-external-services/damages-external-services/pom.xml: Unrecognised tag: 'packaging' (position: START_TAG seen ...</version>\n <packaging>... @7:16) @ /Users/a0m0466/workspace/damage.damages-orchestrator.dc-external-services/damages-external-services/pom.xml, line 7, column 16 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
# 1 楼答案
父级POM可以通过包装POM声明。它并不打算被分发,因为它只从其他项目中引用
Maven parent pom可以包含几乎所有内容,这些内容可以继承到子pom文件中,例如
父母POM
儿童POM
更多参考https://howtodoinjava.com/maven/maven-parent-child-pom-example/
# 2 楼答案
包装
<packaging>
标签应该在</parent>
标签之外