java 打包
1.利用maven打包
在pom.xml中添加一下依赖:
<build> <plugins> <plugin> <!-- 指定项目编译时的java版本和编码方式 --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <target>1.8</target> <source>1.8</source> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.0</version> <configuration> <archive> <manifest> <mainClass>com.netty.client.SignalClient</mainClass> <!-- 指定入口类路径 --> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> <!-- jar包后缀,生成的jar包形式为:project-1.0-SNAPSHOT-jar-with-dependencies.jar --> </descriptorRefs> </configuration> <!-- 添加此项后,可直接使用mvn package | mvn install --> <!-- 不添加此项,需直接使用mvn package assembly:single --> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
在Terminal中运行如下指令:
mvn clean
mvn package -Dmaven.test.skip=true
2. 利用springboot中的maven插件打包
<properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.2.6.RELEASE</version> <configuration> <mainClass>com.zf.bm.ConnectApplication</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>