我正在尝试使用Maven构建Javahibernate项目。但是,当我尝试执行此操作时,似乎没有依赖项吗?
我的项目中现在有了这个pom.xml:
<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>net.viralpatel.hibernate</groupId> <artifactId>HibernateHelloWorldXML</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>HibernateHelloWorldXML</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>ejb3-persistence</artifactId> <version>1.0.1.GA</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.3.1.GA</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.10</version> </dependency> </dependencies> </project>
当我尝试使用mvn进行构建时,出现此错误:
[WARNING] An error occurred during dependency resolution. Failed to retrieve javax.transaction:jta-1.0.1B Caused by: Failure to find javax.transaction:jta:jar:1.0.1B in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced Try downloading the file manually from: http://java.sun.com/products/jta Then, install it using the command: mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -Drepository Id=[id] Path to dependency: 1) net.viralpatel.hibernate:HibernateHelloWorldXML:jar:1.0-SNAPSHOT 2) org.hibernate:hibernate-annotations:jar:3.3.1.GA 3) org.hibernate:hibernate:jar:3.2.6.ga 4) javax.transaction:jta:jar:1.0.1B javax.transaction:jta:jar:1.0.1B from the specified remote repositories: central (http://repo.maven.apache.org/maven2, releases=true, snapshots=false)
我搜索了此错误,发现很多人必须在其pom.xml文件中更改其hibernate核心依赖版本,但似乎我没有hibernate核心,那么如何解决此问题?
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.3.2.ga</version> </dependency>
它具有建议的JTA 1.1依赖性。
要么
您可以在pom.xml或settings.xml 中将“ http://download.java.net/maven/2 ” 添加为新存储库
<repository> <id>java.net.m2repo</id> <name>java.net Maven 2 Repository</name> <url>http://download.java.net/maven/2/</url> <layout>default</layout> </repository>
对于Sun或oracle提供的任何JEE库。
<repositories> <repository> <id>GlassFish</id> <name>GlassFish Maven Repository</name> <url>http://download.java.net/maven/glassfish/</url> </repository> <repository> <id>java.net.m1repo</id> <name>java.net Maven 1 Repository</name> <url>http://download.java.net/maven/1/</url> <layout>legacy</layout> </repository> <repository> <id>java.net.m2repo</id> <name>java.net Maven 2 Repository</name> <url>http://download.java.net/maven/2/</url> <layout>default</layout> </repository> </repositories>