2018-06-02 23:14:27 +03:00
|
|
|
package com.baeldung.config;
|
2017-02-09 01:34:42 +02:00
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
|
|
|
|
2018-10-04 22:18:12 +03:00
|
|
|
import com.mongodb.MongoClient;
|
|
|
|
|
2017-02-09 01:34:42 +02:00
|
|
|
@Configuration
|
2018-06-02 23:14:27 +03:00
|
|
|
@EnableMongoRepositories(basePackages = "com.baeldung.repository")
|
2017-02-09 01:34:42 +02:00
|
|
|
public class SimpleMongoConfig {
|
|
|
|
|
|
|
|
@Bean
|
2018-10-04 22:18:12 +03:00
|
|
|
public MongoClient mongo() throws Exception {
|
2017-02-09 01:34:42 +02:00
|
|
|
return new MongoClient("localhost");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
public MongoTemplate mongoTemplate() throws Exception {
|
|
|
|
return new MongoTemplate(mongo(), "test");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|