2014-10-28 198 views
0

Im遵循http://www.concretepage.com/spring-4/spring-4-rest-web-service-json-example-tomcat的REST風格的Web服務教程。有春天框架依賴。而不是下載的二進制文件,並把它在lib目錄的我已經包括像使用Maven構建Eclipse項目

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>com.concretepage</groupId> 
<artifactId>Spring4</artifactId> 
<version>1</version> 
<packaging>war</packaging> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.1.1.RELEASE</version> 
    </parent> 

    <dependencies> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>4.0.3.RELEASE</version> 
    </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
     </dependency> 
    </dependencies> 

</project> 

pom.xml的依賴,當我用鼠標右鍵單擊pom.xml - Run>Maven build它給了我下面的錯誤在控制檯

enter image description here

[錯誤]未爲此構建指定目標。您必須按以下格式指定 有效生命週期階段或目標: 或:[:] :. 可用生命週期階段:驗證,初始化, 生成源,過程源,生成資源, 過程資源,編譯,過程類,生成測試源, 過程測試源,生成測試 測試編譯,過程測試類,測試,準備包,包, 預集成測試,集成測試,後集成測試,驗證, 安裝,部署,預清理,清理,後清理,前站點,站點, 後站點,站點部署。

我的爪哇(螞蟻,Maven的,gradle這個等),請指導我怎樣才能成功地創建從ABV提到嘖嘖一個war文件的生成機制,沒有現成的經驗。

Regards

回答

1

一般來說,您需要首先創建該項目的構建配置,你可以簡單地選擇Run>Maven build之前。創建構建配置基本上意味着定義在構建期間應該執行哪些maven目標。

要做到這一點,你需要做到以下幾點:

  • 選擇Run>Maven build...
  • 在出現給構建配置的名稱,然後確定哪些目標應該運行的窗口
  • (相當標準的目標是clean install - 如圖所示) enter image description here
  • 點擊Apply然後Run - 那麼這將關閉窗口,並運行構建

現在將來在點擊Run>Maven build時,默認情況下會選擇此配置。

+0

感謝您的時間,它的工作 – dakait 2014-10-30 04:26:25

1

嘗試添加您的項目名稱。將「包裝」設置爲「戰爭」;默認的包裝是「jar」。 (該組ID是默認你父母的,也是如此版)

<artifactId>your.project.name</artifactId> 
<packaging>war</packaging> 

當您嘗試使用Maven的Eclipse之外建立它 - 它的工作原理? (從命令行,mvn clean install ...)

BTW你使用的是什麼版本的eclipse?在開普勒我看不到Run> build with maven的選項。 enter image description here

嘗試到「首選項」屏幕,並看到Maven的配置: enter image description here

+0

感謝您的時間我編輯了我的問題,包括完整的'pom.xml' plz看看 – dakait 2014-10-28 07:44:47

+0

更新了我的答案... – OhadR 2014-10-28 07:56:28

+0

sry用屏幕截圖再次更新我的問題,右鍵單擊pom.xml然後選擇maven build – dakait 2014-10-28 08:02:59