找不到目标“单”与Maven运行MVN包

我试图编译一些Java类与Maven生成一个可执行的JAR文件,它是独立找不到目标“单”与Maven运行MVN包

<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>grids</groupId>

<artifactId>grids</artifactId>

<version>0.0.1-SNAPSHOT</version>

<name>MainMap_Challange</name>

<description>Tickets and Events System</description>

<build>

<sourceDirectory>src</sourceDirectory>

<plugins>

<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.5.1</version>

<configuration>

<descriptorRefs>

<descriptorRef>jar-with-dependencies</descriptorRef>

</descriptorRefs>

</configuration>

<executions>

<execution>

<id>make-assembly</id> <!-- this is used for inheritance merges -->

<phase>package</phase> <!-- bind to the packaging phase -->

<goals>

<goal>single</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

我想产生一个独立的jar文件一样解释在这里 https://maven.apache.org/plugins/maven-assembly-plugin/usage.html

错误我得到的是:

[INFO] Scanning for projects... 

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building MainMap_Challange 0.0.1-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.335 s

[INFO] Finished at: 2017-12-02T20:08:49Z

[INFO] Final Memory: 5M/15M

[INFO] ------------------------------------------------------------------------

[ERROR] Could not find goal 'single' in plugin org.apache.maven.plugins:maven-compiler-plugin:3.5.1 among available goals compile, help, testCompile -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1]

http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException

在命令行上运行 “MVN包” 时

回答:

不使用maven-compiler-plugin,使用maven-assembly-plugin

<plugin> 

<artifactId>maven-assembly-plugin</artifactId>

<configuration>

<archive>

<manifest>

<mainClass>fully.qualified.MainClass</mainClass>

</manifest>

</archive>

<descriptorRefs>

<descriptorRef>jar-with-dependencies</descriptorRef>

</descriptorRefs>

</configuration>

<executions>

<execution>

<id>make-assembly</id> <!-- this is used for inheritance merges -->

<phase>package</phase> <!-- bind to the packaging phase -->

<goals>

<goal>single</goal>

</goals>

</execution>

</executions>

</plugin>

source

以上是 找不到目标“单”与Maven运行MVN包 的全部内容, 来源链接: utcz.com/qa/258148.html

回到顶部