开发者

How to compile hibernate project with maven?

I am novice to maven (as well as to hibernate) but want to learn both. I have downloaded a sample project from hibernate.org and now trying to compile it with maven but getting following error:

[INFO] Scanning for projects... Downloading: http://repo1.maven.org/maven2/org/hibernate/hibernate-parent/3.5.2- Final/hibernate-parent-3.5.2-Final.pom [INFO] Unable to find resource 'org.hibernate:hibernate-parent:pom:3.5.2-Final' 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.hibernate:hibernate-tutorials:pom:null

Reason: Cannot find parent: org.hibernate:hibernate-parent for project: org.hibe rnate:hibernate-tutorials:pom:null for project org.hibernate:hibernate-tutorials :pom:null

[INFO] ------------------------------------------------------------------------ [INFO] Trace org.apache.maven.reactor.MavenExecutionException: Cannot find parent: org.hibern ate:hibernate-parent for project: org.hibernate:hibernate-tutorials:pom:null for project org.hibernate:hibernate-tutorials:pom:null 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:6 0) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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.hibernate:hibernate-parent for project: org.hibernate:hibernate-tutorials: pom:null for project org.hibernate:hibernate-tutorials:pom:null at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(D efaultMavenProjectBuilder.java:1396) at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def aultMavenProjectBuilder.java:823) at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFi leInternal(DefaultMavenProjectBuilder.java:508) at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMave nProjectBuilder.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.hibernate :hibernate-parent' not found in repository: Unable to download the artifact from any repository

org.hibernate:hibernate-parent:pom:3.5.2-Final

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

for project org.hibernate:hibernate-parent at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepo sitory(DefaultMavenProjectBuilder.java:605) at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(D efaultMavenProjectBuilder.java:1392) ... 18 more Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository

org.hibernate:hibernate-parent:pom:3.5.2-Final

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

  开发者_如何学运维  at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De

faultArtifactResolver.java:228) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De faultArtifactResolver.java:90) at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepo sitory(DefaultMavenProjectBuilder.java:558) ... 19 more Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to downl oad the artifact from any repository at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(Def aultWagonManager.java:404) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De faultArtifactResolver.java:216) ... 21 more

Looks it is trying to download libraries from the web? can I not provide all jars required by my sample project on local drive? Is there any quick solution of my problem, to start with? or I should study maven and hibernate in details before I start it?


Hibernate 3.5.2-Final is not available in the Maven central repository but is available in JBoss repository. So add the following to your pom.xml (or your settings.xml):

<repositories>
  <repository>
    <id>jboss-public-repository-group</id>
    <name>JBoss Public Repository Group</name>
    <url>http://repository.jboss.org/nexus/content/groups/public</url>
  </repository>
  ...
</repositories>

See also

  • Maven Getting Started - Users
  • JBoss Maven repository changes


I should study maven and hibernate in details before I start it?

Yes. Maven can be simple, or extremely complex depending on how far you want to go with it. Hibernate can be complex to set up if you're doing more than the basics. I'd suggest learning one at a time.

Looks it is trying to download libraries from the web? can I not provide all jars required by my sample project on local drive?

Yes and Yes. By default (I believe) maven both looks on your local filesystem and out on the interwebs. It attempts to keep your local copy in sync. But you can set it up to just use your local repository if you'd like.

Is there any quick solution of my problem, to start with?

Maybe. Change the version number from 3.5.2-Final to 3.3.2.GA for hibernate-parent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜