MongoTemplate configuration with the annotation @Configuration
This commit is contained in:
parent
fbc3539b6e
commit
fe7c28fef9
|
@ -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>
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue