Failed to convert property value of type 'java.lang.String' to required type 'com.mongodb.ServerAddr
spring 连接 mongdb集群报此错误有可能是 spring-data-mongodb pom引入的包版本太高。
我使用 1.8.2.RELEASE 启动偶尔会报上面错误,改成 1.7.2.RELEASE 无此错误了
<mongo:mongo-client id="mongoclient"
replica-set="${mongodb.replicaset}" credentials="${mongodb.credentials}">
<mongo:client-options connections-per-host="200" max-wait-time="120000" min-connections-per-host="5"/>
</mongo:mongo-client>
<mongo:db-factory id="mongoDbFactory" dbname="${mongodb.dbname}" mongo-ref="mongoclient"/>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean>
pom 文件
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.7.2.RELEASE</version>
</dependency>