基本的Maven帮助 - 无法编译

时间:2010-11-27 21:20:07

标签: maven-2 maven

我正在努力教自己Maven。我买了一本书。我在第一个例子,似乎无法让它工作。我尝试输入“mvn compile”,但它失败了。我添加了pom.xml文件和输出。你能指出我正确的方向来编译吗?抱歉,pom.xml的格式化。我不知道如何让xml正确显示。感谢

Source

<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>org.beginningee6.book</groupId>
<artifactId>chapter02</artifactId>
<version>2.0</version>
<name>Chapter 02 - JPA</name>

<parent>
    <groupId>org.beginningee6.book</groupId>
    <artifactId>chapters</artifactId>
    <version>2.0</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>${javax.persistence-version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>${eclipselink-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>


dan@desktop:~/Documents/Beginning_Java_EE_6_with_GlassFish_3_Second_Edition-4636/chapter02$ mvn compile
[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/org/beginningee6/book/chapters/2.0/chapters-2.0.pom
[INFO] Unable to find resource 'org.beginningee6.book:chapters:pom:2.0' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.beginningee6.book:chapter02:jar:2.0

Reason: Cannot find parent: org.beginningee6.book:chapters for project: org.beginningee6.book:chapter02:jar:2.0 for project org.beginningee6.book:chapter02:jar:2.0


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Cannot find parent: org.beginningee6.book:chapters for project: org.beginningee6.book:chapter02:jar:2.0 for project org.beginningee6.book:chapter02:jar:2.0
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find parent: org.beginningee6.book:chapters for project: org.beginningee6.book:chapter02:jar:2.0 for project org.beginningee6.book:chapter02:jar:2.0
    at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1396)
    at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:823)
    at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
    at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
    at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
    at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
    ... 12 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.beginningee6.book:chapters' not found in repository: Unable to download the artifact from any repository

  org.beginningee6.book:chapters:pom:2.0

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

 for project org.beginningee6.book:chapters
    at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605)
    at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1392)
    ... 18 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository

  org.beginningee6.book:chapters:pom:2.0

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


    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
    at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
    ... 19 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
    at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
    ... 21 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 

1 个答案:

答案 0 :(得分:1)

正如本书作者Antonio Goncalves in this thread所述:

  

您可以尝试使用 you'll find here

的最新版代码吗?

(在Beginning Java EE 6 Platform with GlassFish 3: From Novice to Professional预订Apress