有一个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>
&#34; index.xml&#34;装配文件
<?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&#34; jar-with-dependencies&#34;在Storm中使用,必须排除slf4j-log4j12包,Storm也包含它。但有一个&#34;索引器&#34;它中的class是独立使用的,它需要slf4j-log4j12包才能记录,运行&#34; maven install&#34;,得到:
[警告]在此工件包含过滤器中从未触发以下模式: o&#39; org.slf4j:slf4j-log4j12&#39;
如何在&#34; index.xml&#34;中修复此问题汇编文件?
答案 0 :(得分:0)
我认为唯一的方法是通过不同的maven配置文件定义不同的依赖策略。 建议参考hadoop maven config。