mvn打包springboot项目

添加mvn plugin依赖

指定当前项目运行main方法的类路径

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
                <!--这里写上main方法所在类的路径-->
                <configuration>
                    <mainClass>server.demo.DemoApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
			</plugin>
		</plugins>
	</build>
 

使用cmd命令行的方式打包

使用IDE打包可能会失败

mvn package

打包完成后运行

java -jar jar文件名

猜你喜欢

转载自blog.csdn.net/qq_42418169/article/details/109290257