首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven / Hibernate --为什么在ConstraintViolationException上使用NoClassDefFoundError?

Maven / Hibernate --为什么在ConstraintViolationException上使用NoClassDefFoundError?
EN

Stack Overflow用户
提问于 2011-05-22 18:33:22
回答 1查看 3.2K关注 0票数 1

我正在使用Maven构建这个Hibernate应用程序。它按照我在Eclipse中期望的方式运行(使用Maven插件)。但是,当我从命令行"mvn全新安装“jar文件,然后尝试使用java -jar目标/JarFileName.jar在jar中运行该程序时,应用程序最终会死于:

代码语言:javascript
复制
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/exception/ConstraintViolationException

我在.m2目录的hibernate jar中看到了这个类。

这是我在POM文件中获得的与hibernate相关的最新依赖项。(在尝试让它工作时,我已经在这方面进行了几次迭代。)

代码语言:javascript
复制
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>3.3.2.GA</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-annotations</artifactId>
   <version>3.4.0.GA</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-commons-annotations</artifactId>
   <version>3.3.0.ga</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-entitymanager</artifactId>
   <version>3.4.0.GA</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-tools</artifactId>
   <version>3.2.3.GA</version>
   <scope>test</scope>
</dependency>

我遗漏了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-23 15:54:55

如果您打开已构建的JAR文件(可以使用7-zip/winip/winRar/etc打开它),请检查您是否可以在目录中看到POM中列出的Hibernate JAR。

很高兴它为您指明了正确的方向。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6087355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档