博客
关于我
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 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置服务器文件上传与下载
查看>>
Nginx 配置清单(一篇够用)
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
Nginx 集成Zipkin服务链路追踪
查看>>
nginx 集群配置方式 静态文件处理
查看>>
nginx+php的搭建
查看>>
nginx+tomcat+memcached
查看>>
Nginx+Tomcat实现动静分离
查看>>
nginx+Tomcat性能监控
查看>>
nginx+uwsgi+django
查看>>
nginx+vsftp搭建图片服务器
查看>>
Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流
查看>>
nginx-vts + prometheus 监控nginx
查看>>
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>