打包jar 运行

转载: https://blog.csdn.net/weixin_34352449/article/details/93626436

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<archive>
<manifest>
<mainClass>demo.NettyServer</mainClass>
</manifest>
</archive>
<descriptorRefs>

<!-- 这个jar-with-dependencies是assembly预先写好的一个,组装描述引用 -->

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

</descriptorRefs>

<!--工程名-->

<finalName>${project.name}</finalName>

</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

java -jar devicelog-service-jar-with-dependencies.jar

用maven导出的包中,如果没有在pom文件中将依赖包打进去,是没有依赖包。
1.打包时指定了主类,可以直接用java -jar xxx.jar。
2.打包是没有指定主类,可以用java -cp xxx.jar 主类名称(绝对路径)。

 

springboot 一般项目构建文件都配置好了,不需要配置以上信息,直接 java -jar XXX.jar 

 

posted @ 2020-08-26 10:16  zshblog  阅读(162)  评论(0编辑  收藏  举报