SpringBoot -- 以 jar 包运行(以及常见错误分析)
7.SpringBoot 以 jar 包运行
- 打包
- 在打包之前先要导入一个maven项目的打包插件,使用 springInitializr 创建的 maven 项目,已经自动导入了。如果没有需要手动导入。将下面代码,放进 Pom.xml 里面即可。
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins>
</build>
- 打包步骤
- 运行 jar 包
首先点进 Idea 的终端 Terminal,然后按如下步骤操作
- 如果产生如下错误,说明maven版本过低,重新装一个高版本即可,安装过程看这篇博客
- 下面这个错误是由于你的 JDK 环境变量没有正确配置。