3

我正在尝试使用 ServicesResourceTransformer 来处理我在构建 fatjar 时遇到的一些问题(在此处记录),但是当 maven 尝试使用它时我得到一个 ClassNotFound :

ClassNotFoundException: Class name which was explicitly given in configuration using 'implementation' attribute: 'org.apache.maven.plugins.shade.resource.ServicesResourceTransfor‌​mer' cannot be loaded

我的完整 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>embedly.reverb</groupId>
<artifactId>reverb</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>reverb</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-bundle</artifactId>
        <version>1.14</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-grizzly2</artifactId>
        <version>1.14</version>
    </dependency>

    <dependency>
        <groupId>com.sun.grizzly</groupId>
        <artifactId>grizzly-servlet-webserver</artifactId>
        <version>1.9.18-i</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey.jersey-test-framework</groupId>
        <artifactId>jersey-test-framework-grizzly</artifactId>
        <version>1.4</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.5</version>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <manifestEntries>
                            <Main-Class>Main</Main-Class>
                            <Build-Number>1</Build-Number>
                        </manifestEntries>
                    </transformer>
                </transformers>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
      </plugin>
    </plugins>
</build>

请让我知道是否有更多信息会有所帮助;这个Java tang对我来说是新的。

4

1 回答 1

1

尝试 2.0 的插件。看起来那个类是最近才引入的。

于 2012-10-30T18:20:04.607 回答