Maven 打包问题

239 阅读1分钟

1、问题描述

今天给聚合工程统一打包时出现这样一个异常packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging. @ line 4, column 109

2、问题分析

出错的pom.xml文件如下:

<?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>cn.edu.njust</groupId>
    <artifactId>mango_pom</artifactId>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>../mango_common</module>
        <module>../mango_core</module>
        <module>../mango</module>
    </modules>

</project>

这是由于统一打包的工程不生成jar包文件,所以需要使用pom格式打包,即<packaging>pom</packaging>。完整正确pom.xml文件

<?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>
    <packaging>pom</packaging>

    <groupId>cn.edu.njust</groupId>
    <artifactId>mango_pom</artifactId>
    <version>1.0-SNAPSHOT</version>

    <modules>
        <module>../mango_common</module>
        <module>../mango_core</module>
        <module>../mango</module>
    </modules>

</project>