spring boot使用mongo:code1
来源:互联网 发布:淘宝纠纷报警有用吗 编辑:程序博客网 时间:2024/05/22 14:15
package hello;import org.springframework.context.annotation.Bean;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.core.convert.MappingMongoConverter;import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;import com.mongodb.MongoClient;@Configuration@EnableMongoRepositories(basePackages = { "hello" })public class MongoConfiguration { @Bean public MongoDbFactory mongoDbFactory() throws Exception { // create mongoClient with ip,port,dbName return new SimpleMongoDbFactory(new MongoClient("localhost", 27017), "test"); } //must use MappingMongoConverter, else will throw persistententity must not be null @Bean public MongoTemplate mongoTemplate(MappingMongoConverter mappingMongoConverter) throws Exception { return new MongoTemplate(mongoDbFactory(), mappingMongoConverter); }}
0 0
- spring boot使用mongo:code1
- Spring boot mongo pom
- spring boot 集成mongo配置
- code1
- mongo 使用spring模板 笔记
- spring data mongo使用小记
- Spring boot初始化Mongo数据库(将.json文件持久化到Mongo数据库)
- spring+mongo
- 开始使用Spring Boot
- Spring Boot 使用
- spring-boot 使用log4j
- spring boot 使用@ConfigurationProperties
- spring boot使用redis
- 为什么使用spring boot
- Spring Boot Profile使用
- spring boot使用redis
- Spring Boot 使用JdbcTemplate
- III. 使用Spring Boot
- 学习KVC和KVO
- H5+App开发框架汇总
- Apache CarbonData
- Session的应用
- JAVA 中线程队列BlockingQueue的使用
- spring boot使用mongo:code1
- mac 下终端访问文件出现“Permission Denied”解决方案
- SpringMvc登录检查
- Hbase API中常用类介绍和使用
- HTML常用代码的搜集
- c++中用new和不用new创建对象的本质区别
- 题目1105:字符串的反码
- How to get source code from APK
- ActiveMQ消息发送和接收