mongodb - Grails、Spring Security 和 Mongo

标签 mongodb grails spring-security

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

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.

最佳答案

如果您只是注释掉 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'

干杯!

关于mongodb - Grails、Spring Security 和 Mongo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36341541/

相关文章:

javascript - 在 MongoDB 3.6 NodeJS 驱动程序中断言?以及在使用promise实现时如何使用assert?

java - Spring Security :Can not construct instance of org. springframework.security.core.userdetails.UserDetails

java - 未调用 Spring Security Authentication UserDetailsS​​ervice 实现类

node.js - 在已从用户注册中添加其他字段的模式中使用 mongoose 在 mongodb 中插入数组

javascript - 通过 Mongoose 回调传递值

c# - MongoDB 在正则表达式查询中使用索引

servlets - quartz 作业调用另一个应用程序的servlet

grails - 为什么Grails不使用提供的联接表名称(多对多关系)

java - 将连续尾部输出重定向到 UI

google-app-engine - 在 Google App Engine 上启用 Oauth2sso