使用hibernate的嵌入式jar的Grails应用程序

时间:2014-03-19 22:16:53

标签: hibernate grails jar grails-domain-class

我在Grails中有一个Web应用程序,运行得很好。 但我有一个问题,我需要在我的应用程序中嵌入另外两个jar项目,以编程方式进行hibernate。

问题在于嵌入这个罐子我的网络应用程序正在获取jar的实体并更新他们在数据库中的架构,而另一个更高的问题是罐子无法解决问题。实例化实体,因为他们给了我一个" org.hibernate.MappingException:未知实体:..."

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

3 个答案:

答案 0 :(得分:0)

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

这被视为常规的hibernate配置。

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

将com.example.dao.model.Address添加到grails known entities

答案 1 :(得分:0)

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

//BuildConfig.groovy
dependencies {
    compile('com.example.app1:1.0') {
        transitive = false
    }

    //or
    compile('com.example.app1:1.0') {
        excludes "hibernate", "something-else"
    }
}

有关详细信息,请参阅Grails Configurations

答案 2 :(得分:0)

有人可以帮忙吗?因为我不需要排除hibernate,也不能在grails中包含jar实体,因为它们是不同的数据库..

有人?