【问题标题】:NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProviderNoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
【发布时间】:2014-11-03 12:46:24
【问题描述】:

我的 pom.xml 中定义了依赖项

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-commons-annotations</artifactId>
    <version>3.3.0.ga</version>
</dependency>

我在 C:/User/.m2/repository/org/hibernate/hibernate-commons-annotations/3.3.0.ga 中有上述 jar

我在 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();

我明白了:

Exception in thread "main" java.lang.NoClassDefFoundError: 
    org/hibernate/annotations/common/reflection/MetadataProvider

我已经尝试将 hibernate-commons-annotion jar 直接添加到我的构建路径以及我的 WEB-INF/lib 中,但还没有成功

这是以相同的方式设置并在我构建的另一个应用程序上正常运行,不需要导入注释 jar。 有什么想法吗?

【问题讨论】:

  • 在通过其他解决方案搜索了几个小时后,我认为问这个问题不会有什么坏处,因为其他人可能也有同样的问题,但是抱歉在 SO-a place for Technical 上发布问题问题。已标记。
  • 转到 API,并检查该类是否存在。如果找不到,则表示存在可比性问题。该方法可能已被弃用,否则。
  • 兼容性问题:找到兼容的版本。

标签: java hibernate maven


【解决方案1】:

显然 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>

来源https://hibernate.atlassian.net/browse/ANN-711

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-20
    • 2012-10-20
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    • 2019-06-04
    • 2012-02-02
    • 2018-07-09
    相关资源
    最近更新 更多