與朋友一起,我們爲我們的學校開展一個項目,我們最後。 問題是,在Eclipse中,我們的java程序正常工作,並且使用eclipse生成的JAR。但是我們需要在執行命令mvn package時生成一個JAR。這個JAR沒有找到外部JAR的類,這是我們第一次使用Maven,所以你可以幫我做一個很好的pom.xml,當我們使用外部JAR生成一個JAR時,它會生成一個JAR文件? 還有就是POM:問題使用MAVEN使用外部JAR製作JAR
<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>
<groupId>coo.project</groupId>
<artifactId>COO-DONJON</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>COO-DONJON</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
\t <dependency>
\t <groupId>junit</groupId>
\t <artifactId>junit</artifactId>
\t <version>4.12</version>
\t </dependency>
\t <dependency>
\t \t <groupId>javazoom</groupId>
\t <artifactId>jlayer</artifactId>
\t <version>1.0.1</version>
\t </dependency>
</dependencies>
<build>
\t <plugins>
\t \t <plugin>
\t \t \t \t <groupId>org.apache.maven.plugins</groupId>
\t \t \t \t <artifactId>maven-dependency-plugin</artifactId>
\t \t \t \t <executions>
\t \t \t \t \t <execution>
\t \t \t \t \t \t <id>copy-dependencies</id>
\t \t \t \t \t \t <phase>prepare-package</phase>
\t \t \t \t \t \t <goals>
\t \t \t \t \t \t \t <goal>copy-dependencies</goal>
\t \t \t \t \t \t </goals>
\t \t \t \t \t \t <configuration>
\t \t \t \t \t \t \t <outputDirectory>${project.build.directory}</outputDirectory>
\t \t \t \t \t \t \t <overWriteReleases>true</overWriteReleases>
\t \t \t \t \t \t \t <overWriteSnapshots>true</overWriteSnapshots>
\t \t \t \t \t \t \t <overWriteIfNewer>true</overWriteIfNewer>
\t \t \t \t \t \t </configuration>
\t \t \t \t \t </execution>
\t \t \t \t </executions>
\t \t </plugin>
\t \t <plugin>
\t \t \t <groupId>org.apache.maven.plugins</groupId>
\t \t \t <artifactId>maven-javadoc-plugin</artifactId>
\t \t \t <version>2.10.4</version>
\t \t </plugin>
\t \t <plugin>
\t \t \t <groupId>org.apache.maven.plugins</groupId>
\t \t \t <artifactId>maven-jar-plugin</artifactId>
\t \t \t <version>3.0.2</version>
\t \t \t <configuration>
\t \t \t \t <archive>
\t \t \t \t \t <manifest>
\t \t \t \t \t \t <addClasspath>true</addClasspath>
\t \t \t \t \t \t <mainClass>coo.project.App</mainClass>
\t \t \t \t \t </manifest> \t \t
\t \t \t \t </archive>
\t \t \t </configuration>
\t \t </plugin>
\t
\t </plugins>
</build>
</project>
它的工作原理,THKü – BlaCkOmN
:-)沒有問題。 –