[英]Spring Data MongoDB - Always connecting with default parameters
I am using MongoDB 3.0.0 with Spring, accessing with spring-data-mongodb
and mongo-java-driver
我在Spring上使用MongoDB 3.0.0,使用spring-data-mongodb
和mongo-java-driver
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.7.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.0.2</version>
</dependency>
In test environment, I perform JUnit tests on object validation only, so I don't load any MongoTemplate
, nor any mongo-related configuration. 在测试环境中,我仅对对象验证执行JUnit测试,因此,我不会加载任何MongoTemplate
或任何与mongo相关的配置。
For some reason, I always get in the log: 出于某种原因,我总是进入日志:
2015-06-22 15:06:17,049 GMT [main] (SLF4JLogger.java:71) INFO driver.cluster: Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=50}
2015-06-22 15:06:17,290 GMT [cluster-ClusterId{value='558808495d12e1d8bcc6ef19', description='null'}-localhost:27017] (SLF4JLogger.java:71) INFO driver.connection: Opened connection [connectionId{localValue:1, serverValue:55}] to localhost:27017
2015-06-22 15:06:17,290 GMT [cluster-ClusterId{value='558808495d12e1d8bcc6ef19', description='null'}-localhost:27017] (SLF4JLogger.java:71) INFO driver.cluster: Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 0, 0]}, minWireVersion=0, maxWireVersion=3, electionId=null, maxDocumentSize=16777216, roundTripTimeNanos=434000}
Is it possible that in the spring-data-mongodb
I get a Bean definition that causes the connection described in the log ? 是否有可能在spring-data-mongodb
获得导致日志中描述的连接的Bean定义? Is there any way to prevent it ? 有什么办法可以预防吗?
I think Spring loads it automatically. 我认为Spring会自动加载它。 You can disable it by disabling auto configuration for the following classes 您可以通过禁用以下类别的自动配置来禁用它
@EnableAutoConfiguration(exclude = {
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,
org.springframework.boot.autoconfigure.mongo.MongoDataAutoConfiguration })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.