2016-06-15 65 views
0

enter image description here我在日食中發現了這個瘋狂的問題。我可以在命令提示符下使用命令「maven clean package」運行Maven build。但是,當我嘗試在eclipse中通過右鍵單擊 - >運行 - > Maven構建來構建相同的應用程序時,在我添加爲「clean package」的配置中。它扔我的錯誤的從命令提示符工作的Maven構建,但不是來自Eclipse的

The project com.svu.core:cUT:1.0.0-SNAPSHOT (E:\CU-SVN\pom.xml) has 1 error 
[ERROR]  Non-resolvable parent POM: Failure to find com.zenmonics.core:epom:pom:1.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 11, column 10 -> [Help 2] 

它在pom.xml中同樣的錯誤,但它是如何從命令提示符下運行,但不會從Eclipse IDE中。由於這個原因,我無法在我的構建路徑中獲得Maven依賴關係。

<project xmlns="http://maven.apache.org/POM/4.0.0" x mlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<!-- <groupId>com.svu.core</groupId>--> 
<artifactId>cUT</artifactId> 
<version>1.0.0-SNAPSHOT</version> 
<name>pom :: cUT</name> 
<packaging>pom</packaging> 

<parent> <---------- Here it throws error 
    <groupId>com.svu.core</groupId> 
    <artifactId>epom</artifactId> 
    <version>1.0.0</version> 
</parent> 

enter image description here

+0

您的eclipse是指向JRE還是JDK?在這裏看到:http://stackoverflow.com/questions/21099072/eclipse-maven-error-no-compiler-is-provided-in-this-environment/21099229#21099229 –

+0

它指向JDK 1.7更新了截圖。 – Syed

+0

您能否爲您的項目顯示文件夾結構? –

回答

0

請檢查您的工作空間Maven倉庫中是否存在或不存在的..!

+0

.m2文件夾存在於我的系統下C盤&存儲庫也存在它下面 – Syed

+0

我的意思是你的eclipse工作區。不是你的系統驅動器..!如果您的工作區中存在Maven倉庫,您可以在eclipse中構建maven項目 –

+0

如何檢查? – Syed

0

請嘗試把你的pom.xml。你的錯誤表示問題出在pom.xml @ line 11, column 10

問題是parent在您當前的pom中未檢測到pom。請嘗試以下

<project> 

    <parent> 
    <groupId>com.svu.core</groupId> 
    <artifactId>epom</artifactId> 
    <version>1.0.0</version> 
    </parent> 

    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.svu.core</groupId>   <--- Same group id as your parent 
    <artifactId>cUT</artifactId> 


參考:http://maven.apache.org/guides/introduction/introduction-to-the-pom.html

注:我沒有足夠的聲譽在你的問題發表評論。

+0

用pom更新。xml問題 – Syed

+0

請檢查更新 – programmer

0

當以下工作

cd cUT 
mvn compile 

但同樣的模塊不能在Eclipse是編譯。可能你已經改變了Maven配置,並且它的Eclipse視圖不再是最新的。例如,如果在Eclipse之外更改pom.xml文件,或者在不考慮位於項目路徑中的地方(請參閱您的其他question),這種情況可能會發生。

在Eclipse中選擇Project Explorer模塊cUT。按ALT-F5(執行maven - >更新項目)。選擇您項目的所有模塊,檢查是否已啓用update project configuration from pom.xml,然後單擊「進行」。

+0

能否請您詳細說明「但是在Eclipse中無法編譯相同的模塊,可能您已經更改了Maven配置,並且它的Eclipse視圖不再是最新的。」米不能理解它 – Syed

+0

我沒有改變配置中的任何東西。我的settings.xml在.m2文件夾下丟失,這可能是沒有獲得Maven依賴的原因? – Syed

+0

@Syed'settings.xml'不是必須的文件。對於其他問題,請查看我的更新答案。是否在你的任何'pom.xml'中引用'com.zenmonics.core'?你的父模塊'epom'的'pom.xml'是怎麼樣的? – SubOptimal

相關問題