2013-08-01 50 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变量,要么在所有依赖项(不推荐)中用实际值替换变量。