Created
January 21, 2017 21:30
-
-
Save arthurportas/0cc95a5bb97eebeb0689c62ca7dde3f8 to your computer and use it in GitHub Desktop.
Sample spring-boot Fongo configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.arthurportas.config; | |
import com.github.fakemongo.Fongo; | |
import com.mongodb.Mongo; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.data.mongodb.config.AbstractMongoConfiguration; | |
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; | |
/** | |
* Created by arthurportas on 21/01/2017. | |
*/ | |
@ComponentScan(basePackages = "com.arthurportas.mongodb.example") | |
@EnableMongoRepositories(basePackages = "com.arthurportas.mongodb.example.repository") | |
@Configuration | |
public class FongoConfiguration extends AbstractMongoConfiguration { | |
@Override | |
protected String getDatabaseName() { | |
return "demo-test"; | |
} | |
@Bean | |
@Override | |
public Mongo mongo() { | |
// uses fongo for in-memory tests | |
return new Fongo("mongo-test").getMongo(); | |
} | |
@Override | |
protected String getMappingBasePackage() { | |
return "com.arthurportas.mongodb.example.domain"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment