Maven executable Jar throws error on start

This question already has an answer here:

  • How can I create an executable JAR with dependencies using Maven? 33 answers

  • If I'm correct, maven-jar-plugin creates a jar with all the compiled .class files, but without the dependencies.

    I'd recommend using maven-assembly-plugin and binding it to the package execution phase, that way it would be built when running mvn install

    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>com.pwc.scfa.pensareautomatio3.Main</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>
    

    See this answer for more information.

    链接地址: http://www.djcxy.com/p/29630.html

    上一篇: 可执行jar与依赖使用maven

    下一篇: Maven可执行文件Jar在启动时抛出错误