#382 - Adapt examples to Spring Boot 2.1 changes.
Replace custom configuration with the one that Boot provides. Adapt to DataMongo configuration that requires a MongoClient bean.
This commit is contained in:
@@ -15,22 +15,9 @@
|
||||
*/
|
||||
package example.springdata.mongodb.people;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration;
|
||||
import org.springframework.data.mongodb.core.mapping.event.LoggingEventListener;
|
||||
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;
|
||||
|
||||
import com.mongodb.reactivestreams.client.MongoClient;
|
||||
import com.mongodb.reactivestreams.client.MongoClients;
|
||||
|
||||
/**
|
||||
* Simple configuration that registers a {@link LoggingEventListener} to demonstrate mapping behavior when streaming
|
||||
@@ -38,29 +25,11 @@ import com.mongodb.reactivestreams.client.MongoClients;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@SpringBootApplication(exclude = { MongoAutoConfiguration.class, MongoDataAutoConfiguration.class })
|
||||
@EnableReactiveMongoRepositories
|
||||
@AutoConfigureAfter(EmbeddedMongoAutoConfiguration.class)
|
||||
@RequiredArgsConstructor
|
||||
class ApplicationConfiguration extends AbstractReactiveMongoConfiguration {
|
||||
|
||||
private final Environment environment;
|
||||
@SpringBootApplication
|
||||
class ApplicationConfiguration {
|
||||
|
||||
@Bean
|
||||
public LoggingEventListener mongoEventListener() {
|
||||
return new LoggingEventListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
@DependsOn("embeddedMongoServer")
|
||||
public MongoClient reactiveMongoClient() {
|
||||
int port = environment.getProperty("local.mongo.port", Integer.class);
|
||||
return MongoClients.create(String.format("mongodb://localhost:%d", port));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDatabaseName() {
|
||||
return "reactive";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user