Cloudfoundry + SpringData + MongoDB ...无法部署
Posted
技术标签:
【中文标题】Cloudfoundry + SpringData + MongoDB ...无法部署【英文标题】:Cloudfoundry + SpringData + MongoDB...can't deploy 【发布时间】:2012-09-30 22:35:16 【问题描述】:我有一个基于 Spring Data 和 MongoDB 的简单项目。当我使用以下 Spring 上下文将该项目部署到云时:
<?xml version="1.0" encoding="UTF-8"?>
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/架构/上下文http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://schema.cloudfoundry.org/spring @ 987654325@ http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/data/蒙哥http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
<context:property-placeholder location="classpath:services.properties" />
<context:annotation-config />
<bean id="gadgetizerApplication" class="it.ids.gadgetizer.GadgetizerApplication">
</bean>
<bean id="gadgetizerService" class="it.ids.gadgetizer.service.impl.GadgetServiceImpl">
<property name="mongoTemplate" ref="mongoTemplate" />
<property name="mailSender" ref="mailSender"/>
<property name="velocityEngine" ref="velocityEngine"/>
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongoDbFactory" />
</bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.xxx.xxx" />
<property name="username" value="xxx"/>
<property name="password" value="xxx"/>
<property name="port" value="2525"/>
</bean>
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
</value>
</property>
<beans profile="development">
<mongo:db-factory id="mongoDbFactory" dbname="$mongo.dbname" host="$mongo.host" port="$mongo.port" />
</beans>
<beans profile="cloud">
<cloud:mongo-db-factory id="mongoDbFactory" service-name="$mongo.cloud.service_name" />
</beans>
它失败了:
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.mongodb.core.MongoTemplate]: Constructor threw exception; nested exception is java.lan
.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:110)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 68 more
Caused by: java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.util.Assert.notNull(Assert.java:123)
at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:196)
at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:185)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 70 more
Stopping Tomcat because the context stopped.
一个月前它还在工作。 API 有什么变化?
谢谢
【问题讨论】:
问题是运行时 jar 用户。我使用的是 cloudfoundry-runtime-0.8.1,而最新的是 0.8.2。解决了。 当我推送它时,我收到将套接字连接到我的 mongodb 的错误。我是否必须添加 Cloud Foundry 依赖项? 【参考方案1】:您的问题似乎是运行时 jar。请尝试使用最新的 cloudfoundry-runtime。
【讨论】:
以上是关于Cloudfoundry + SpringData + MongoDB ...无法部署的主要内容,如果未能解决你的问题,请参考以下文章
Cloudfoundry 上 node.js 应用程序的蓝/绿部署
Bluemix/CloudFoundry + Meteor - 如何重置项目?