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包。

相關文章
相關標籤/搜索