参考:eclipse创建springboot项目的三种方法 https://blog.csdn.net/mousede/article/details/81285693
在eclipse中如何导入springboot项目:https://blog.csdn.net/qq_22860341/article/details/89841188
方法一:使用springboot插件
1)、安装STS插件
2)、安装插件导向窗口完成后,在eclipse右下角将会出现安装插件的进度,等插件安装完成后重启eclipse生效
3)、新建spring boot项目
选择需要的依赖:
4)、项目启动, Finsh,OK done!
(a)、运行maven build报错No goals have been specified for this build.
运行maven报错:
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
解决办法,在pom.xml添加如下配置:
<build> <defaultGoal>compile</defaultGoal> </build>
(b)、关于Maven项目build时出现No compiler is provided in this environment的处理
[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.436 s [INFO] Finished at: 2017-06-28T11:16:07+08:00 [INFO] Final Memory: 10M/151M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project manage: Compilation failure [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [ERROR] -> [Help 1]
解决办法:https://blog.csdn.net/lslk9898/article/details/73836745
方法二:使用springboot构建工具
1、使用构建工具自动生成项目基本架构, 自动创建web应用
1)、工具自动创建:http://start.spring.io/
2)、勾选需要的依赖:
其中,Group Id 是包名,Artifact Id 是项目名
2、在eclipse中引入maven项目
1)、点击Generate Project下载项目压缩包
解压后,使用eclipse,Import -> Existing Maven Projects -> Next ->选择解压后的文件夹-> Finsh,OK done!
补充:
1、常用maven命令
clean:清除目标目录中的生成结果。
generate-sources:开发环境与代码分离,很少使用,执行这个命令可以通过查看.classpath和.project两个文件来查看变化。
install:在本地库中安装jar
test:运行项目中的单元测试
package:根据项目生成jar文件
tomcat*:run:启动tomcat,前提是在项目的pom.xml文件中添加了tomcat插件
eclipse:eclipse:生成Eclipse项目文件,即.classpath和.project文件
compile:编译源代码
dependency:sources:下载项目依赖的jar包的源码包
2、Eclipse maven配置:
参考:Eclipse上Maven环境配置使用 (全) https://www.cnblogs.com/tangshengwei/p/6341462.html
3、Eclipse maven “update project”的意思:
update project本身是更新项目的意思。用在mave中是指pom.xml文件改动之后,需要执行Mavne/Update Project来更新外部依赖的jar包。
4、eclipse使用插件集成springboot项目pom.xml第一行报unknown错误
添加 <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>即可 ,指定版本号,中间自己根据需要更改