1

我正在开发一个使用 mongodb、内置在 grails 中并使用 oauth2 作为身份验证服务的应用程序。我已经构建了服务和控制器(我认为),并且正在尝试运行我的服务器以手动测试与谷歌的连接性。我遇到了无法解决的“创建名称为 transactionManagerPostProcessor ... 的 bean 时出错”。我知道我需要安装一个为我处理“事务”的插件,或者在 resources.groovy 中创建一个 bean。

我已经对此进行了大量研究和阅读,但在过去的几天里,我一直处于死胡同,试图实现这一点。有人能告诉我如何解决这个问题,创建正确的 bean,或者安装正确的插件吗?下面的部分堆栈跟踪,带有指向完整堆栈跟踪的链接:

|Loading Grails 2.3.4
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
............................................
|Running Grails application
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Error |
2014-01-16 09:30:52,840 [localhost-startStop-1] ERROR context.GrailsContextLoader  -             Error initializing the application: Error creating bean with name     'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTransactionManager': Cannot resolve reference to bean 'mongoDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDatastore': Cannot resolve reference to bean 'mongoMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: org/springframework/format/datetime/DateFormatterRegistrar

完整的堆栈跟踪可以在以下位置找到: http: //pastebin.com/5mW5uwtu

我试过添加

static transaction = 'mongo'

到调用谷歌对用户进行身份验证的服务。这是我在 stackoverflow 上的一个类似问题上找到的解决方案。我还在构建配置中摆弄了不同的插件和依赖项。不知道还有什么可以尝试的。

谢谢!

4

1 回答 1

0

为了使用一些插件解决这个问题,我在 resources.groovy 的 beans 块中添加了以下内容

// some plugins need a transaction manager, 
// although the mongo one isn't properly transactional
// and could produce unexpected results in some cases.
springConfig.addAlias('transactionManager', 'mongoTransactionManager')

但是,您看到的特定错误与找不到 Spring 类 DateFormatterRegistrar 有关。您使用的是最新版本的 Grails(例如 2.3+)和 mongo 插件吗?您是否在 BuildConfig 中添加了 mongo 插件作为编译插件依赖项?:

compile ":mongodb:1.3.3"
于 2014-01-17T17:23:11.340 回答