java 为 hibernate 3.6 配置 pom.xml
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16353683/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Configure pom.xml for hibernate 3.6
提问by Martin Dvoracek
I've tried to configure pom.xml
file for my Spring 3
and Hibernate 3.6
application.
The relevant part of pom.xml
looks like this:
我试图pom.xml
为我的Spring 3
和Hibernate 3.6
应用程序配置文件。的相关部分pom.xml
如下所示:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.17.1-GA</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
Nevertheless, if I don't include javassist.jar
library directly to my buildpath as an External jar
, I keep getting java.lang.ClassNotFoundException
. Is there anything wrong in my pom.xml
, due it doesn't download this dependency when building the project?
不过,如果我不包括javassist.jar
直接库构建路径我作为一个External jar
,我不断收到java.lang.ClassNotFoundException
。我的有什么问题pom.xml
吗,因为它在构建项目时没有下载这个依赖项?
采纳答案by Evgeniy Dorofeev
Try hibernate-entitymanager
instead of hibernate-core
.
尝试hibernate-entitymanager
代替hibernate-core
.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.3.Final</version>
</dependency>
This will include all necessary dependencies transitively. Check maven dependency hierarchy after you make this change.
这将包括所有必要的依赖关系。进行此更改后,请检查 Maven 依赖关系层次结构。
BTW the lastest available version of hibernate in maven central is 4.1.18
顺便说一句,maven central 中最新可用的 hibernate 版本是 4.1.18
回答by Himanshu Bhardwaj
java.lang.ClassNotFoundException should also mention the name of class which was not found.
java.lang.ClassNotFoundException 还应提及未找到的类的名称。
First you verify the jar you are trying to copy is getting copied into the build path or not.
If 1 is yes, then expand the javassist-3.17.1-GA.jar to check if the missing class file for which you got exception is present or not.
首先,您验证您尝试复制的 jar 是否已复制到构建路径中。
如果 1 为 yes,则展开 javassist-3.17.1-GA.jar 以检查是否存在您遇到异常的丢失类文件。
The external jar which resolves the issues, try to find out its version, maybe you can get it from MANIFEST.MF file of that jar.
解决问题的外部jar,试着找出它的版本,也许你可以从那个jar的MANIFEST.MF文件中得到它。
May be something was refactored which is causing the problem.
可能是重构了导致问题的原因。
回答by Koty
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.1.0.CR2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>