【问题标题】:Grails application with embedded jars using hibernate使用 hibernate 的带有嵌入式 jar 的 Grails 应用程序
【发布时间】:2014-03-19 22:16:53
【问题描述】:

我在 Grails 中有一个 Web 应用程序,它运行得很好。 但是我有一个问题,我需要嵌入到我的应用程序中的另外两个 jars 项目具有休眠编程配置。

问题是嵌入这个罐子我的网络应用程序正在获取罐子的实体并在数据库中更新它们的模式,另一个更高的问题是罐子无法实例化实体,因为它们给了我一个“ org.hibernate.MappingException:未知实体:...”

有人遇到过这个问题吗?在这种情况下有什么好的解决方案?

【问题讨论】:

    标签: hibernate grails jar grails-domain-class


    【解决方案1】:

    您可以使用 grails-app/conf/hibernate/hibernate.cfg.xml 文件将其他实体传递给 grails 休眠配置。

    这被视为常规休眠配置。

     <mapping package="com.example" />
     <mapping class="com.example.dao.model.Address" />
    

    将 com.example.dao.model.Address 添加到 grails 已知实体

    【讨论】:

      【解决方案2】:

      您可以从依赖项中排除传递依赖项。您可以指定不引入所有传递依赖项,也可以明确排除您不需要的依赖项。

      //BuildConfig.groovy
      dependencies {
          compile('com.example.app1:1.0') {
              transitive = false
          }
      
          //or
          compile('com.example.app1:1.0') {
              excludes "hibernate", "something-else"
          }
      }
      

      详情请参考Grails Configurations

      【讨论】:

      • dmahapatro,感谢您的回答..但我需要一个以上的休眠配置并且不排除依赖项..
      猜你喜欢
      • 1970-01-01
      • 2017-10-21
      • 1970-01-01
      • 2010-09-22
      • 1970-01-01
      • 2014-09-25
      • 1970-01-01
      • 2013-04-05
      • 2012-03-30
      相关资源
      最近更新 更多