【问题标题】:Adding JBoss AS 7 modules on Eclipse using Maven or JBoss Tools使用 Maven 或 JBoss Tools 在 Eclipse 上添加 JBoss AS 7 模块
【发布时间】:2012-05-08 11:51:11
【问题描述】:

我正在将我的项目迁移到 JBoss AS 7,并且我已经阅读了一些关于它的模块的信息。我的问题很简单(我认为),我不知道如何在开发阶段包含这些模块。例如,我使用 hibernate,在 Eclipse 中,使用 JBoss Tools 和 JBoss AS 6,我只需要说项目将使用 JBoss 7 并且它们的所有“jar”都可用。但是使用 JBoss 7,hibernate-core 对我不可用。我知道我可以选择在我的 pom 上将 hibernate-core 添加为“提供”,但是还有另一种方法吗?

【问题讨论】:

  • 你是依赖 Hibernate API 还是仅仅依赖 JPA?
  • 现在,我正在使用 Hibernate API

标签: java maven jboss7.x jboss-tools


【解决方案1】:

我会说在你的 pom 上添加 hibernate-core 作为“提供”并添加

Dependency: org.hibernate

发送至您的META-INF/MANIFEST.MF

<dependencies>
    <module name="org.hibernate" />
</dependencies>

jboss-deployment-structure.xml 是要走的路。通过这种方式,您可以在运行时访问与 JBoss 捆绑的 Hibernate,而无需将它们包含在您的部署中。只要确保您使用与 JBoss 相同的 Hibernate 版本(JBoss AS 7.1.1 的 Hibernate 4.0.1)。另请查看Developer Guide

【讨论】:

  • 是的,但是像 altanis 所说的那样添加完整的 api 会更好,因为我有所有可用的 JBoss 罐子。但我想我也需要那个依赖,因为我在运行时遇到错误,谢谢!
  • 你好。这对我不起作用。我有 JBoss AS 7.1.1。 Hibernate 4.0.1.Final 设置为 pom.xml 中提供的。当我尝试jboss-deployment-structure.xml 时,我收到以下错误:org.jboss.resteasy.spi.UnhandledException: java.lang.ExceptionInInitializerErrororg.hibernate.MappingException: Unable to create AuditStrategy[org.hibernate.envers.strategy.DefaultAuditStrategy] instance. 如果我使用清单解决方案,我会收到错误java.lang.NoClassDefFoundError: org/hibernate/HibernateException。我正在使用 Netbeans Maven Web 应用程序项目模板
  • 我也尝试过使用这个解决方案,但没有成功stackoverflow.com/a/30759509/5618563 ...我到这里 java.lang.NoClassDefFoundError: org/hibernate/HibernateException。当然,当我在 pom.xml 中使用运行时或编译范围时,应用程序运行良好
【解决方案2】:

【讨论】:

  • 正是我想要的!谢谢!
猜你喜欢
  • 1970-01-01
  • 2012-10-09
  • 1970-01-01
  • 2012-01-08
  • 2012-04-16
  • 2011-10-05
  • 2014-07-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多