MongoTemplate configuration with the annotation @Configuration

This commit is contained in:
coach88 2015-07-28 11:07:22 +03:00
parent fbc3539b6e
commit fe7c28fef9
2 changed files with 28 additions and 3 deletions

View File

@ -7,7 +7,6 @@
<packaging>jar</packaging>
<name>spring-data-mongodb</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -18,8 +17,6 @@
<rest-assured.version>2.4.1</rest-assured.version>
</properties>
<dependencies>
<dependency>

View File

@ -0,0 +1,28 @@
package org.baeldung.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
@Configuration
@EnableMongoRepositories
public class MongoConfig extends AbstractMongoConfiguration {
@Override
protected String getDatabaseName() {
return "test";
}
@Override
public Mongo mongo() throws Exception {
return new MongoClient("127.0.0.1", 27017);
}
@Override
protected String getMappingBasePackage() {
return "org.baeldung";
}
}