基本 Maven 帮助 -- 无法编译

发布于 2024-10-04 23:02:06 字数 6616 浏览 3 评论 0原文

我正在尝试自学 Maven。我买了一本书。我正在使用第一个示例,但似乎无法使其工作。我尝试输入“mvncompile”但失败了。我添加了 pom.xml 文件和输出。你能给我指出正确的方向来编译它吗?抱歉 pom.xml 的格式。我不确定如何让 xml 正确显示。谢谢

来源

<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: 

I am trying to teach myself Maven. I bought a book. Im on the first example and can not seem to get it to work. I try to type "mvn compile" and it fails. Ive added the pom.xml file and the output. Can you point me in the right direction to get this to compile. Sorry for the formatting of the pom.xml. Im not sure how to get xml to display correctly. Thanks

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: 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走过海棠暮 2024-10-11 23:02:06

正如该书的作者 Antonio Goncalves 在此线程中

您可以尝试使用最新版本的代码你会在这里找到

(书籍使用 GlassFish 开始 Java EE 6 平台3:从新手到专业人士,位于Apress

As mentioned by the author of the book Antonio Goncalves in this thread:

Can you try with the latest version of the code that you'll find here

(book Beginning Java EE 6 Platform with GlassFish 3: From Novice to Professional at Apress)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文