- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用Grails 2.3.8和MongoDB的项目中进行开发。在我的项目中,我包括MongoDB GORM plugin和hibernate来简化数据库连接的工作:
BuildConfig.groovy
// default config stuff here
grails.project.dependency.resolution = {
...
plugins {
...
compile ":mongodb:3.0.3"
runtime ":hibernate:3.6.10.4"
}
}
environments {
development {
grails {
mongo {
host = "localhost"
port = 27017
databaseName = "myDB"
// runs without --auth option needs no authentication
}
}
}
production {
grails {
mongo {
databaseName = "myDB"
username = "user"
password = "*****"
replicaSet = [
"master-host:port",
"slave1-host:port",
"slave2-host:port"
]
}
}
}
}
grails test test-app --debug-fork --stacktrace --verbose -integration
Error Fatal error running tests: 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': FactoryBean threw exception on object creation; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms; nested exception is com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
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': FactoryBean threw exception on object creation; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms; nested exception is com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.codehaus.groovy.grails.transaction.ChainedTransactionManagerPostProcessor.registerAdditionalTransactionManagers(ChainedTransactionManagerPostProcessor.java:114)
at org.codehaus.groovy.grails.transaction.ChainedTransactionManagerPostProcessor.postProcessBeanFactory(ChainedTransactionManagerPostProcessor.java:101)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:633)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:156)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:169)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:127)
at org.codehaus.groovy.grails.project.loader.GrailsProjectLoader$_configureApplication_closure3.doCall(GrailsProjectLoader.groovy:134)
at org.codehaus.groovy.grails.project.loader.GrailsProjectLoader$_configureApplication_closure3.doCall(GrailsProjectLoader.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
at groovy.lang.Closure.call(Closure.java:411)
at groovy.lang.Closure.call(Closure.java:405)
at org.codehaus.groovy.grails.cli.api.BaseSettingsApi.profile(BaseSettingsApi.java:342)
at org.codehaus.groovy.grails.project.loader.GrailsProjectLoader.configureApplication(GrailsProjectLoader.groovy:131)
at org.codehaus.groovy.grails.test.runner.phase.IntegrationTestPhaseConfigurer.prepare(IntegrationTestPhaseConfigurer.groovy:59)
at org.codehaus.groovy.grails.test.runner.phase.TestPhaseConfigurer$prepare.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:89)
at org.codehaus.groovy.grails.test.runner.GrailsProjectTestRunner$_runAllTests_closure7.doCall(GrailsProjectTestRunner.groovy:311)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
at groovy.lang.Closure.call(Closure.java:411)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.callClosureForMapEntry(DefaultGroovyMethods.java:3873)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1354)
at org.codehaus.groovy.runtime.dgm$149.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.grails.test.runner.GrailsProjectTestRunner.runAllTests(GrailsProjectTestRunner.groovy:301)
at org.codehaus.groovy.grails.test.runner.GrailsProjectTestRunner.runAllTests(GrailsProjectTestRunner.groovy:216)
at org.codehaus.groovy.grails.test.runner.GrailsProjectTestRunner.runAllTests(GrailsProjectTestRunner.groovy)
at org.codehaus.groovy.grails.test.runner.GrailsProjectTestRunner$runAllTests$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.grails.cli.fork.testing.ForkedGrailsTestRunner.runInstance(ForkedGrailsTestRunner.groovy:128)
at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProjectClassExecutor.run(ForkedGrailsProjectClassExecutor.groovy:74)
at org.codehaus.groovy.grails.cli.fork.testing.ForkedGrailsTestRunner.main(ForkedGrailsTestRunner.groovy:75)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDatastore': FactoryBean threw exception on object creation; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms; nested exception is com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:151)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
... 70 more
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms; nested exception is com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:69)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:1829)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:393)
at org.grails.datastore.mapping.mongo.MongoDatastore.initializeIndices(MongoDatastore.java:285)
at org.grails.datastore.mapping.mongo.MongoDatastore.createMongoTemplate(MongoDatastore.java:276)
at org.grails.datastore.mapping.mongo.MongoDatastore.afterPropertiesSet(MongoDatastore.java:221)
at org.springframework.beans.factory.InitializingBean$afterPropertiesSet.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at org.grails.datastore.gorm.mongo.bean.factory.MongoDatastoreFactoryBean.getObject(MongoDatastoreFactoryBean.groovy:54)
at org.grails.datastore.gorm.mongo.bean.factory.MongoDatastoreFactoryBean.getObject(MongoDatastoreFactoryBean.groovy)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:144)
... 75 more
Caused by: com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
at com.mongodb.BaseCluster.getServer(BaseCluster.java:87)
at com.mongodb.DBTCPConnector.getServer(DBTCPConnector.java:654)
at com.mongodb.DBTCPConnector.access$300(DBTCPConnector.java:39)
at com.mongodb.DBTCPConnector$MyPort.getConnection(DBTCPConnector.java:503)
at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:451)
at com.mongodb.DBTCPConnector.getPrimaryPort(DBTCPConnector.java:409)
at com.mongodb.DBCollectionImpl.createIndex(DBCollectionImpl.java:339)
at com.mongodb.DBCollection.createIndex(DBCollection.java:564)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:663)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:603)
at org.grails.datastore.mapping.mongo.MongoDatastore$6.doInDB(MongoDatastore.java:341)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:391)
... 85 more
nested exception is com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
最佳答案
集成测试针对“完全成熟”的grails应用程序运行-如果在dev和prod中使用数据库,则需要一个测试。
此外,如果您确实在执行自动化测试部分,则需要一个用于其他测试的测试数据库,因此现在就创建一个。即使此测试未使用它,它也构成了您正在测试的“完整grails环境”的一部分。
在您的Jenkins作业中,您可以传递环境设置以指示测试环境将指定的配置文件用于数据源。我使用存储在test / conf / app-config.groovy中的特定于测试的app-config.groovy文件来执行此操作。该配置指向Jenkins服务器可以看到的一个长期的AWS RDS实例(该数据库不在Jenkins服务器上)。 Jenkins构建步骤主要调用:
grails test-app -Dapp.config.location = test / conf / app-config.groovy集成:
(我在工作中面临着同样的问题,只是为所有三个环境(开发,生产和测试)创建了MySQL数据库。由于我们运行的客户端是在H2,MSSQL,Oracle或MySQL之间进行选择,因此要做更多的事情。
关于mongodb - MongoDB插件-如何使其在测试过程中不创建数据源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31297562/
我正在创建一个管理外部实用程序的多个实例的应用程序,为每个实例提供数据并获取结果。 但是我在编写单元测试时遇到了问题。 如何测试目标方法在被调用时是否真的启动了一个进程(通过属性设置)? 我试过: 让
我意识到“标准”这个词很奇怪,因为测试似乎非常依赖于项目,但是如果我设计了一个非常标准的场景,我希望得到关于我应该关注的测试类型的反馈。 我的团队正在创建一个中型数据驱动的 Web 应用程序。我们正在
在我的设置中,我运行了一个脚本 火车一个模型并开始生成检查点。另一个脚本监视新的检查点和 评估 他们。脚本并行运行,因此评估只是训练之后的一步。 支持这种情况的正确 Tracks 配置是什么? 最佳答
Jenkins三大概念: Job:即为任务 插件:maven构建项目、git拉取代码、ssh插件 工作空间:任务的存储空间,即为git代码的存储空间 开发
我是一名优秀的程序员,十分优秀!