0

我正在申请一项任务。我是初学者。我通过修改老师给我的一个例子来完成这项任务。我尝试使用 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>

4

2 回答 2

3

看起来你错过了${derby-version}财产。

您应该在您的 POM 中将其定义为

<properties>
<derby-version>YOUR_DERBY_VERSION_IDENTIFIER_HERE</derby-version>
</properties>
于 2013-08-01T06:43:07.240 回答
0

从这条线可以清楚地看出

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

maven 在构建期间无法解析 derby-version 值。

因此,要么按照 Raibaz 的建议在 pom 文件中声明 derby-version 变量,要么在所有依赖项中将变量替换为实际值(不推荐)。

于 2013-08-01T06:49:10.233 回答