spring整合mongo报错:Timed Out While Waiting For A Server That Matches AnyServerSelector{} After 10000 Ms

今天在整合mina,让人头疼的是一直报超时错误,调了3个多小时的错误,终于找到原因了,下面是报的错

org.springframework.dao.DataAccessResourceFailureException: 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:71)
	at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:1918)
	at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:412)
	at org.springframework.data.mongodb.core.MongoTemplate.insertDBObjectList(MongoTemplate.java:916)
	at org.springframework.data.mongodb.core.MongoTemplate.doInsertBatch(MongoTemplate.java:807)
	at org.springframework.data.mongodb.core.MongoTemplate.doInsertAll(MongoTemplate.java:787)
	at org.springframework.data.mongodb.core.MongoTemplate.insertAll(MongoTemplate.java:762)

需要说明的是我用的mongo的驱动如下:

 		
			org.mongodb
			mongo-java-driver
			2.12.4
		


将mongo的驱动换成如下超时错误即可解决

 		
			org.mongodb
			mongo-java-driver
			3.0.2
		


关于这个问题程序界的大神给出的回答是:

We just released the 2.12.4 Java driver which contains an improvement to the error message for that MongoTimeoutException.  If you are in a position where you can easily upgrade, please try it.
In 2.12.3, the driver does log connection failures via JUL so there should be INFO-level log messages available as well.

关注我,获取400个的赚钱金点子,轻松开启程序员的副业生涯

spring整合mongo报错:Timed Out While Waiting For A Server That Matches AnyServerSelector{} After 10000 Ms_第1张图片

 

 


 

你可能感兴趣的:(mongo)