Grails,Spring Security和Mongo

时间:2016-03-31 19:00:37

标签: mongodb grails spring-security

我尝试配置Grails 3.1.4 rest-api aplication。我想使用Mongo和Spring Security进行身份验证,但是当我从application.yml h2数据源和hibernate中删除并尝试运行应用程序时,我会遇到很多异常,例如:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceInterceptor':
Cannot create inner bean '(inner bean)#1b3bb287' of type [org.grails.orm.hibernate4.support.AggregatePersistenceContextInterceptor]
while setting constructor argument with key [0]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1b3bb287':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method:
public void org.grails.orm.hibernate4.support.AggregatePersistenceContextInterceptor.setHibernateDatastores(org.grails.orm.hibernate.AbstractHibernateDatastore[]); nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.orm.hibernate.AbstractHibernateDatastore]
found for dependency [array of org.grails.orm.hibernate.AbstractHibernateDatastore]:
expected at least 1 bean which qualifies as autowire candidate for this dependency.

1 个答案:

答案 0 :(得分:0)

如果您只是注释掉application.yml中的默认H2和缓存部分,我可以使用Grails 3.1.7确认此行为。但是,如果我注释掉以下内容,它就会消失:

// compile "org.grails.plugins:hibernate4"

供参考,我使用mongoDB和spring-security-core的以下插件版本:

compile 'org.grails.plugins:mongodb:5.0.6'
compile "org.mongodb:mongodb-driver:3.0.2"
runtime 'org.springframework.data:spring-data-mongodb:1.8.1.RELEASE'
compile 'org.grails.plugins:spring-security-core:3.1.1'

干杯!