2013-08-01 52 views
0

我在爲一個任務做一個應用程序。我是一名初學者。我通過修改我的老師給我的一個例子來完成這項任務。我試圖通過使用maven來使用命令行編譯應用程序。發生構建錯誤。使用maven編譯時出現編譯錯誤(未能解析工件)

Microsoft Windows [版本 6.1.7601] 
版權所有 (c) 2009 Microsoft Corporation。保留所有權利。 

C:\Users\dell>f: 

F:\>cd \COIT13235-s0234380-ass1\assignment 1 

F:\COIT13235-s0234380-ass1\assignment 1> mvn compile 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building folder_a 
[INFO] task-segment: [compile] 
[INFO] ------------------------------------------------------------------------ 
[WARNING] POM for 'commons-cli:commons-cli:pom:1.0:runtime' is invalid. 

Its dependencies (if any) will NOT be available to the current build. 
[INFO] [resources:resources {execution: default-resources}] 
[WARNING] Using platform encoding (GB18030 actually) to copy filtered resources, 
i.e. build is platform dependent! 
[INFO] Copying 1 resource 
Downloading: http://repo1.maven.org/maven2/org/eclipse/persistence/javax.persist 
ence/${derby-version}/javax.persistence-${derby-version}.pom 
[INFO] Unable to find resource 'org.eclipse.persistence:javax.persistence:pom:${ 
derby-version}' in repository central (http://repo1.maven.org/maven2) 
Downloading: http://repo1.maven.org/maven2/org/eclipse/persistence/eclipselink/$ 
{derby-version}/eclipselink-${derby-version}.pom 
[INFO] Unable to find resource 'org.eclipse.persistence:eclipselink:pom:${derby- 
version}' in repository central (http://repo1.maven.org/maven2) 
Downloading: http://repo1.maven.org/maven2/org/apache/derby/derbyclient/${derby- 
version}/derbyclient-${derby-version}.pom 
[INFO] Unable to find resource 'org.apache.derby:derbyclient:pom:${derby-version 
}' in repository central (http://repo1.maven.org/maven2) 
Downloading: http://repo1.maven.org/maven2/org/apache/derby/derby/${derby-versio 
n}/derby-${derby-version}.pom 
[INFO] Unable to find resource 'org.apache.derby:derby:pom:${derby-version}' in 
repository central (http://repo1.maven.org/maven2) 
Downloading: http://repo1.maven.org/maven2/org/eclipse/persistence/javax.persist 
ence/${derby-version}/javax.persistence-${derby-version}.jar 
Downloading: http://repo1.maven.org/maven2/org/apache/derby/derbyclient/${derby- 
version}/derbyclient-${derby-version}.jar 
[INFO] Unable to find resource 'org.eclipse.persistence:javax.persistence:jar:${ 
derby-version}' in repository central (http://repo1.maven.org/maven2) 
Downloading: http://repo1.maven.org/maven2/org/eclipse/persistence/eclipselink/$ 
{derby-version}/eclipselink-${derby-version}.jar 
[INFO] Unable to find resource 'org.apache.derby:derbyclient:jar:${derby-version 
}' in repository central (http://repo1.maven.org/maven2) 
Downloading: http://repo1.maven.org/maven2/org/apache/derby/derby/${derby-versio 
n}/derby-${derby-version}.jar 
[INFO] Unable to find resource 'org.eclipse.persistence:eclipselink:jar:${derby- 
version}' in repository central (http://repo1.maven.org/maven2) 
[INFO] Unable to find resource 'org.apache.derby:derby:jar:${derby-version}' in 
repository central (http://repo1.maven.org/maven2) 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Failed to resolve artifact. 

Missing: 
---------- 
1) org.eclipse.persistence:javax.persistence:jar:${derby-version} 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=org.eclipse.persistence -DartifactId=ja 
vax.persistence -Dversion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file 

    Alternatively, if you host your own repository you can deploy the file there: 

     mvn deploy:deploy-file -DgroupId=org.eclipse.persistence -DartifactId=java 
x.persistence -Dversion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file -D 
url=[url] -DrepositoryId=[id] 

    Path to dependency: 
     1) task1:folders:jar:2.0 
     2) org.eclipse.persistence:javax.persistence:jar:${derby-version} 

2) org.apache.derby:derbyclient:jar:${derby-version} 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=org.apache.derby -DartifactId=derbyclie 
nt -Dversion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file 

    Alternatively, if you host your own repository you can deploy the file there: 

     mvn deploy:deploy-file -DgroupId=org.apache.derby -DartifactId=derbyclient 
-Dversion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -Dr 
epositoryId=[id] 

    Path to dependency: 
     1) task1:folders:jar:2.0 
     2) org.apache.derby:derbyclient:jar:${derby-version} 

3) org.eclipse.persistence:eclipselink:jar:${derby-version} 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=org.eclipse.persistence -DartifactId=ec 
lipselink -Dversion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file 

    Alternatively, if you host your own repository you can deploy the file there: 

     mvn deploy:deploy-file -DgroupId=org.eclipse.persistence -DartifactId=ecli 
pselink -Dversion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file -Durl=[u 
rl] -DrepositoryId=[id] 

    Path to dependency: 
     1) task1:folders:jar:2.0 
     2) org.eclipse.persistence:eclipselink:jar:${derby-version} 

4) org.apache.derby:derby:jar:${derby-version} 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=org.apache.derby -DartifactId=derby -Dv 
ersion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file 

    Alternatively, if you host your own repository you can deploy the file there: 

     mvn deploy:deploy-file -DgroupId=org.apache.derby -DartifactId=derby -Dver 
sion=${derby-version} -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -Dreposit 
oryId=[id] 

    Path to dependency: 
     1) task1:folders:jar:2.0 
     2) org.apache.derby:derby:jar:${derby-version} 

---------- 
4 required artifacts are missing. 

for artifact: 
    task1:folders:jar:2.0 

from the specified remote repositories: 
    central (http://repo1.maven.org/maven2) 



[INFO] ------------------------------------------------------------------------ 
[INFO] For more information, run Maven with the -e switch 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1 second 
[INFO] Finished at: Thu Aug 01 16:07:06 EST 2013 
[INFO] Final Memory: 8M/75M 
[INFO] ------------------------------------------------------------------------ 
'cmd' 不是內部或外部命令,也不是可運行的程序 
或批處理文件。 
F:\COIT13235-s0234380-ass1\assignment 1> 

這是我的pom.xml文件的一部分。

<modelVersion>4.0.0</modelVersion> 
<groupId>task1</groupId> 
<artifactId>folders</artifactId> 
<packaging>jar</packaging> 
<version>2.0</version> 
<name>folder_a</name> 

<dependencies> 
    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>javax.persistence</artifactId> 
     <version>${derby-version}</version><!--<scope>provided</scope>--> 
    </dependency> 
    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>eclipselink</artifactId> 
     <version>${derby-version}</version><!--<scope>provided</scope>--> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.derby</groupId> 
     <artifactId>derbyclient</artifactId> 
     <version>${derby-version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.derby</groupId> 
     <artifactId>derby</artifactId> 
     <version>${derby-version}</version><!--<scope>test</scope>--> 
    </dependency> 
</dependencies> 

回答

3

你好像缺少${derby-version}財產。

你應該在你的POM定義爲

<properties> 
<derby-version>YOUR_DERBY_VERSION_IDENTIFIER_HERE</derby-version> 
</properties> 
+0

謝謝。我修好了。我修改了pom文件是一個子文件。因此我錯過了父文件中的一些依賴關係。 –

0

從這一行很顯然,

mvn install:install-file -DgroupId=org.eclipse.persistence 
-DartifactId=eclipselink -Dversion=${derby-version} -Dpackaging=jar 
-Dfile=/path/to/file 

Maven是不能夠解決在編譯時間德比版本值。

因此,要麼Raibaz建議在你的pom文件中聲明derby-version變量,要麼在所有依賴項(不推薦)中用實際值替換變量。