Eclipse搭建springboot项目(一)springboot搭建

参考:eclipse建立springboot项目的三种方法 https://blog.csdn.net/mousede/article/details/81285693html

方法一:使用springboot插件java

  1)、安装STS插件web

  2)、安装插件导向窗口完成后,在eclipse右下角将会出现安装插件的进度,等插件安装完成后重启eclipse生效spring

    3)、新建spring boot项目apache

 

   选择须要的依赖:tomcat

   4)、项目启动, Finsh,OK done!springboot

  a)、运行maven build报错No goals have been specified for this build.架构

  运行maven报错:eclipse

[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添加以下配置:maven

<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构建工具

一、使用构建工具自动生成项目基本架构, 自动建立web应用
   1)、工具自动建立:http://start.spring.io/

    

  2)、勾选须要的依赖:

  其中,Group Id 是包名,Artifact Id 是项目名

二、在eclipse中引入maven项目

  1)、点击Generate Project下载项目压缩包

  解压后,使用eclipse,Import -> Existing Maven Projects -> Next ->选择解压后的文件夹-> Finsh,OK done!

 

 补充:
一、经常使用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包的源码包

二、Eclipse maven配置:

参考:Eclipse上Maven环境配置使用 (全) https://www.cnblogs.com/tangshengwei/p/6341462.html

三、Eclipse maven “update project”的意思:

update project自己是更新项目的意思。用在mave中是指pom.xml文件改动以后,须要执行Mavne/Update Project来更新外部依赖的jar包。

相关文章
相关标签/搜索