Skip to content

Instantly share code, notes, and snippets.

@arthurportas
Created January 21, 2017 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurportas/0cc95a5bb97eebeb0689c62ca7dde3f8 to your computer and use it in GitHub Desktop.
Save arthurportas/0cc95a5bb97eebeb0689c62ca7dde3f8 to your computer and use it in GitHub Desktop.
Sample spring-boot Fongo configuration
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