小编典典

将Hibernate 3.5.x添加到Maven pom.xml构建中

hibernate

我像这样将JBoss Maven存储库添加到我的pom.xml文件中…

 <repositories>
        <repository>
            <id>jboss</id>
            <url>http://repository.jboss.org/maven2/</url>        
        </repository>
    </repositories>

我像这样添加了Hibernate本身…

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.5.1-Final</version>
    </dependency>

但是,当我尝试构建我的应用程序时,会看到此错误…。

Downloading: http://repository.jboss.org/maven2//org/hibernate/hibernate/3.5.1-Final/hibernate-3.5.1-Final.jar
[INFO] Unable to find resource 'org.hibernate:hibernate:jar:3.5.1-Final' in repository jboss (http://repository.jboss.org/maven2/)
Downloading: http://repo1.maven.org/maven2/org/hibernate/hibernate/3.5.1-Final/hibernate-3.5.1-Final.jar
[INFO] Unable to find resource 'org.hibernate:hibernate:jar:3.5.1-Final' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.hibernate:hibernate:jar:3.5.1-Final

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate -Dversion=3.5.1-Final -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.hibernate -DartifactId=hibernate -Dversion=3.5.1-Final -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) stakeholdersupdate:stakeholdersupdate:war:1.0
    2) org.hibernate:hibernate:jar:3.5.1-Final

----------
1 required artifact is missing.

阅读 315

收藏
2020-06-20

共1个答案

小编典典

正如Seanizer所提到的,org.hibernate:hibernate:pom:3.5.1-Final工件是一种类型的聚合模块pom(它聚合HibernateCore模块)。因此,您确实可以通过指定来依赖它<type>pom</type>。但是我个人会声明对所需模块的依赖,例如对于HibernateEntity Manager:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-entitymanager</artifactId>
  <version>3.5.1-Final</version>
</dependency>

或对于Hibernate Core:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>3.5.1-Final</version>
</dependency>
2020-06-20