我的老板让我使用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/
文件夹的内容,如果它走了那么远)
webstart-maven-plugin不会创建一个包含依赖项的JAR ,它会沿着创建一个包含lib/
文件夹中依赖项的JAR 。
如果您想将所有内容打包到一个JAR中,则需要使用maven-shade-plugin
。