Package org.springframework.data.rest.core.domain.mongodb

Source Code of org.springframework.data.rest.core.domain.mongodb.MongoDbRepositoryConfig

package org.springframework.data.rest.core.domain.mongodb;

import java.net.UnknownHostException;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import com.mongodb.MongoClient;

/**
* @author Jon Brisbin
*/
@Configuration
@ComponentScan
@EnableMongoRepositories
public class MongoDbRepositoryConfig {

  @Bean
  public MongoDbFactory mongoDbFactory() throws UnknownHostException {
    return new SimpleMongoDbFactory(new MongoClient("localhost"), "spring-data-rest");
  }

  @Bean
  public MongoTemplate mongoTemplate() throws UnknownHostException {
    return new MongoTemplate(mongoDbFactory());
  }

}
TOP

Related Classes of org.springframework.data.rest.core.domain.mongodb.MongoDbRepositoryConfig

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.