一般未一起打包是因为pom不是继承自spring-boot-starter-parent导致的需要在pom.xml文件写入以下配置
1 <build> 2 <plugins> 3 <plugin> 4 <groupId>org.springframework.boot</groupId> 5 <artifactId>spring-boot-maven-plugin</artifactId> 6 <configuration> 7 <mainClass>com.szmirren.Main</mainClass> <!-- 你的主类全路径 --> 8 </configuration> 9 <executions> 10 <execution> 11 <goals> 12 <goal>repackage</goal> 13 </goals> 14 </execution> 15 </executions> 16 </plugin> 17 </plugins> 18 </build> 19 然后再执行:maven install
如果pom继承自spring-boot-starter-parent,打包只需要pom.xml添加如下配置
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>
如果要设置编译版本,跳过单元测试再加如下配置
1 <plugin> 2 <groupId>org.apache.maven.plugins</groupId> 3 <artifactId>maven-compiler-plugin</artifactId> 4 <version>3.2</version> 5 <configuration> 6 <source>1.8</source> 7 <target>1.8</target> 8 <encoding>UTF-8</encoding> 9 </configuration> 10 </plugin> 11 <plugin> 12 <groupId>org.apache.maven.plugins</groupId> 13 <artifactId>maven-surefire-plugin</artifactId> 14 <configuration> 15 <skipTests>true</skipTests> <!--默认关掉单元测试 --> 16 </configuration> 17 </plugin>