[英]Adding Hibernate 3.5.x to a maven pom.xml build
我將JBoss Maven repo添加到我的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.
正如seanizer所提到的, org.hibernate:hibernate:pom:3.5.1-Final
工件是pom
類型的聚合模塊(它聚合了Hibernate Core模塊)。 所以你確實可以通過指定<type>pom</type>
來依賴它。 但我個人會聲明對所需模塊的依賴,例如Hibernate Entity 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>
hibernate工件的類型為pom(意味着它只是其他項目的包裝器)。 做這個:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.5.1-Final</version>
<type>pom</type>
</dependency>
(如果省略類型,maven將嘗試將工件解析為jar,在這種情況下不存在)
這就是我設法將Hibernate和JPA 2添加到我的項目中的方法
. . .
<repositories>
<repository>
<id>JBoss</id>
<name>The "public-jboss" repository group provides a combined view all JBoss community project artifacts</name>
<layout>default</layout>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss</url>
</repository>
</repositories>
<dependencies>
. . .
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.5-Final</version>
</dependency>
. . .
</dependencies>
. . .
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.