1

我的老板告诉我使用 Maven Web Start 插件来生成 JNLP 和签名的 JAR。

问题是无论我如何尝试,我都无法制作包含我的依赖项的 JAR。

我总是面临一个ClassDefNotFound例外

pom.xml

<repositories>
    <repository>
        <releases />
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>mygrid-repository</id>
        <name>myGrid Repository</name>
        <url>http://www.mygrid.org.uk/maven/repository</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo.webstart</groupId>
            <artifactId>webstart-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>

            <executions>
                <execution>
                    <id>package</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jnlp</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                <jnlp>
                    <outputFile>ctScan.jnlp</outputFile>
                    <mainClass>com.test.testScan.App</mainClass>
                </jnlp>

                <libPath>lib</libPath>
                <outputJarVersions>true</outputJarVersions>
                <includes>
                    <include>commons-logging:commons-logging</include>
                    <include>commons-cli:commons-cli</include>
                </includes>
                <sign>
                    <keystore>../../ctKeystore</keystore>
                    <keypass>CreativeKeypass</keypass>
                    <storepass>CreativeKeypass</storepass>
                    <alias>CreativeScan</alias>

                    <dnameCn>Mohcine Wannas</dnameCn>
                    <dnameOu>DARD</dnameOu>
                    <dnameO>Creative technologies</dnameO>
                    <dnameL>Rabat</dnameL>
                    <dnameSt>Rabat</dnameSt>
                    <dnameC>ma</dnameC>

                    <verify>true</verify>
                </sign>

                <pack200>false</pack200>
                <gzip>true</gzip>
                <outputJarVersions>false</outputJarVersions>
                <verbose>true</verbose>

            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>com.test.testScan.App</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>uk.co.mmscomputing</groupId>
        <artifactId>device</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>net.htmlparser.jericho</groupId>
        <artifactId>jericho-html</artifactId>
        <version>3.3</version>
    </dependency>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>0.0</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.jai-imageio</groupId>
        <artifactId>jai-imageio-core-standalone</artifactId>
        <version>1.2-pre-dr-b04-2011-07-04</version>
    </dependency>
    <dependency>
        <groupId>javax.media.jai</groupId>
        <artifactId>com.springsource.javax.media.jai.codec</artifactId>
        <version>1.1.3</version>
    </dependency>
</dependencies>

构建输出

请在此处添加您的构建输出(并且可能是创建的目录结构及其内容,尤其是lib/文件夹的内容,如果它走了那么远)

4

1 回答 1

1

webstart-maven-plugin 不会创建带有依赖项的 JAR,它会在文件夹中创建一个 JAR以及依赖项的 JAR。lib/

如果要将所有内容打包到一个 JAR 中,则需要使用maven-shade-plugin.

于 2013-06-07T00:28:43.433 回答