0
有一個pom.xml包括排除jar包與Maven Assembly插件
<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-與「依賴」是要在Storm中使用的,必須排除slf4j-log4j12包,Storm也包含它。但有一個「索引器」類,它是獨立使用的,它需要slf4j-log4j12包進行日誌記錄,當運行「maven install」時,得到:
[警告]這個工件包含過濾器永遠不會觸發下列模式: o'org.slf4j:slf4j-log4j12'
如何在「index.xml」程序集文件中解決這個問題?