【发布时间】:2014-03-27 13:48:20
【问题描述】:
有一个 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>
<!-- other parts -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.0.0-cdh4.2.1</version>
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
</execution>
<execution>
<id>index</id>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>src/main/assembly/index.xml</descriptor>
</descriptors>
</configuration>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
“index.xml”组装文件
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
<id>index</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>false</unpack>
<includes>
<include>org.slf4j:slf4j-log4j12</include>
</includes>
</dependencySet>
</dependencySets>
<files>
<file>
<source>${project.build.directory}/${artifactId}-${version}-jar-with-dependencies.jar</source>
<fileMode>0644</fileMode>
<outputDirectory>/</outputDirectory>
<destName>${artifactId}-${version}-index.jar</destName>
</file>
</files>
</assembly>
使用 maven 预定义的程序集描述符“jar-with-dependencies”生成的 jar 将在 Storm 中使用,必须排除 slf4j-log4j12 包,Storm 也包含它。但是里面有一个“indexer”类是独立使用的,它需要slf4j-log4j12包来记录,当运行“maven install”时,得到:
[警告] 在此工件包含过滤器中从未触发以下模式: o 'org.slf4j:slf4j-log4j12'
如何解决“index.xml”汇编文件中的这个问题?
【问题讨论】: