博客
关于我
Mongodb事务:基于spring+springmvc
阅读量:797 次
发布时间:2023-02-09

本文共 1137 字,大约阅读时间需要 3 分钟。

spring+springmvc

https://docs.spring.io/spring-data/mongodb/docs/2.2.6.RELEASE/reference/html/#mongo.core
框架版本(必须):
1.MongoDB 4.0.x
2.spring 5.1.1.RELEASE以上
3.spring-data-mongodb:2.1.1.RELEASE以上
4.Mongodb副本集

mongodb.properties 文件

#config for mongoDBmongo.username=brycemongo.password=bryce#mongo.host=192.168.161.128#mongo.port=27088mongo.replSet=10.15.55.100:27017mongo.minConnectionsPerHost=10mongo.threadsAllowedToBlockForConnectionMultiplier=4mongo.connectTimeout=30000mongo.maxWaitTime=3000mongo.socketKeepAlive=falsemongo.socketTimeout=30000mongo.maxConnectionIdleTime=0mongo.maxConnectionLifeTime=0mongo.heartbeatSocketTimeout=20000mongo.heartbeatConnectTimeout=10000mongo.minHeartbeatFrequency=3000mongo.heartbeatFrequency=5000mongo.database=testdb

mongodb.xml文件

代码示例

//加上事务注解    @Transactional(rollbackFor = Exception.class)    public void insertTest(Student student) {            mongoTemplate.insert(student,"student");            //回滚测试            int i = 1/0;    }

转载地址:http://jjffk.baihongyu.com/

你可能感兴趣的文章
Nginx模块 ngx_http_limit_conn_module 限制连接数
查看>>
Nginx模块 ngx_http_limit_req_module 限制请求速率
查看>>
nginx添加模块与https支持
查看>>
nginx状态监控
查看>>
Nginx用户认证
查看>>
Nginx的location匹配规则的关键问题详解
查看>>
Nginx的Rewrite正则表达式,匹配非某单词
查看>>
Nginx的使用总结(一)
查看>>
Nginx的使用总结(三)
查看>>
Nginx的使用总结(二)
查看>>
Nginx的可视化神器nginx-gui的下载配置和使用
查看>>
nginx的平滑升级方法:
查看>>
Nginx的是什么?干什么用的?
查看>>
nginx看这一篇文章就够了
查看>>
Nginx知识详解(理论+实战更易懂)
查看>>
Nginx简单介绍
查看>>
Nginx系列6之-rewirte功能使用案例总结
查看>>
nginx线程模型理解
查看>>
Nginx虚拟主机配置
查看>>
Nginx访问控制_登陆权限的控制(http_auth_basic_module)
查看>>