【问题标题】:hibernate class files are not loading through mavenhibernate 类文件没有通过 maven 加载
【发布时间】:2011-08-28 09:21:48
【问题描述】:
<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>ejb3-persistence</artifactId>
            <version>3.3.2.Beta1</version>
            <type>pom</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.7.Final</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

 <repositories>
    <repository>
        <id>jboss</id>
        <name>JBoss repository</name>
        <url>http://repository.jboss.org/maven2</url>
    </repository>
</repositories>

pom.xml 文件。

但我的 Eclipse 无法识别 SessionFactory、Session、Transaction、HibernateException 等并给出编译时错误。如何解决?

【问题讨论】:

    标签: hibernate maven


    【解决方案1】:

    我认为您使用的存储库 URL 不正确。访问 http://repository.jboss.org/maven2 时收到 403
    查看 JBoss Maven Getting Started 页面上的“配置 Maven 以使用 JBoss 存储库”部分。

    一旦您配置了正确的存储库,请尝试在 Eclipse 之外构建您的项目。如果它构建了,那么您就知道 Maven 项目配置正确。

    如果在成功构建后您的工作区中仍然存在类路径问题,请尝试重新生成 eclipse 设置文件。

    mvn eclipse:clean eclipse:eclipse
    

    【讨论】:

      【解决方案2】:

      从 hibernate 3.6 版开始,核心 ja 包含注释,所以我认为您不需要对注释有显式依赖。除此之外,您不应该遇到编译错误。

      【讨论】:

      • 我收到编译时错误。来自 Eclipse 的引用库不显示 hibernate.jar 文件。
      • 你在你的maven仓库中看到hibernate core jar文件了吗?我最近升级到 3.6.0.Final,从来没有遇到过这样的问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多