Java NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25755760/
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
NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
提问by Kurai Bankusu
I have the dependency defined in my pom.xml
我在 pom.xml 中定义了依赖项
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
I have the above jar in C:/User/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga
我在C:/User/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga 中有上述 jar
I've got a session-factory and datasource configured in a hibernate.cfg.xml and while trying to build the configuration in my main method:
我在 hibernate.cfg.xml 中配置了一个会话工厂和数据源,并尝试在我的主要方法中构建配置:
Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
SessionFactory sessionFactory = configuration.buildSessionFactory(builder.build());
Session session = sessionFactory.openSession();
I get:
我得到:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/hibernate/annotations/common/reflection/MetadataProvider
I've tried adding the hibernate-commons-annotion jar straight in my Build Path as well as my WEB-INF/lib, but no luck yet
我已经尝试在我的构建路径以及我的 WEB-INF/lib 中直接添加 hibernate-commons-annotion jar,但还没有运气
This is setup the same way and running properly on another application I've built, which didn't need the annotations jar imported. Any ideas?
这是以相同的方式设置并在我构建的另一个应用程序上正常运行,该应用程序不需要导入注释 jar。有任何想法吗?
采纳答案by Kurai Bankusu
Apparently 3.3.0.ga was a 'mistake', had to update dependency to use 3.2.0.Final
显然 3.3.0.ga 是一个“错误”,必须更新依赖项才能使用 3.2.0.Final
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.2.0.Final</version>
</dependency>