springboot mongo 不插入_class
来源:互联网 发布:北京蓝鲸网络官网 编辑:程序博客网 时间:2024/05/18 23:12
参考:https://www.2cto.com/database/201608/533434.html
//会忽略 springboot 配置文件里的数据库配置
@Configuration
public class SpringMongoConfig {
public @Bean MongoTemplate mongoTemplate() throws Exception {
//权限验证 MongoCredential
// MongoCredential credential = MongoCredential.createCredential("root", "mydb", "root".toCharArray());
// ServerAddress serverAddress = new ServerAddress("localhost", 27017);
ServerAddress serverAddress = new ServerAddress("192.168.200.100", 27017);
MongoClient mongoClient = new MongoClient(serverAddress);
SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongoClient, "yywdb"); // yywdb 是数据库名
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory);
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, new MongoMappingContext());
//不插入_class
converter.setTypeMapper(new DefaultMongoTypeMapper(null));
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory, converter);
return mongoTemplate;
}
}
- springboot mongo 不插入_class
- mongo中插入的数据含有_class信息
- spring-data-mongo 去除 _class 字段“失败”
- SpringBoot配置MongoDB去掉_class字段
- Mongo插入文档操作
- mongo连接不上
- mongo不停机集群
- 【mongoDB实战】mongo日期插入
- mongo插入long类型数据
- mongo shell 之集合&文档 插入&删除
- mongodb insert time mongo插入时间解决方案
- Spring-Data-MongoDB保存对象的时候,如何不保存_class字段
- [SpringBoot实践]spring-data-mongo自定义Repository接口及其实现
- MongDB副本集(一),SpringBoot链接Mongo副本集
- springboot之集成mybatis mongo shiro druid redis jsp
- mongo连接不上的问题
- MONGO
- mongo
- 文件打开
- 服务器外网无法访问,阿里云服务器外网无法访问解决方案,腾讯云外网无法访问
- 递推(dp)-HDU5366
- linux 安装tar.bz2软件
- Android 版本号对比
- springboot mongo 不插入_class
- 用VS2008打开项目时出现了“初始化 Microsoft Visual SourceSafe 源代码管理提供程序时失败...”解决方式
- Maven打包生成包含所有依赖的jar包
- Android---解析异步消息处理机制
- python用于实现多线程异步交互之生产者消费者模型
- 如何把Kotlin代码转成java代码,如何把java代码转成kotlin代码
- arcgis web for js
- P2255【L1 SOLO 第五场 APIO2009】抢掠计划
- Kotlin基本语法文档记录