@Transactional
事者,生于虑,成于务,失于傲。——管仲 如果想让该类或方法被事务支持,则可以加上@Transactional注解@Transactional有几个参数:value/transactionManager——是用来指定事务管理器,这个不太常用timeout——事务超时时间,为传播特性为PROPAGATION_REQUIRES_NEW和PROPAGATION_REQUIRED定制,创建新事务时旧事务的超时时间,出场率也不是特别高下面的则是常用的参数readOnly——是否为只读事务,如果为true时,进行查询操作效率会更高,但不能进行除查询外的操作,会报错rollbackFor/rollbackForClassName——指定需要回滚的异常noRollbackFor/noRollbackForClassName——指定不需要回滚的异常默认对编译异常不会滚 对非受检异常回滚,例如RuntimeException就会回滚事务 isolation——配置隔离级别事务丢失 回滚丢失——另一个事务回滚导致当前事务丢失 覆盖丢失——另一个事务提交导致当前事务丢失 ...
setInterval
坍圮的殿堂总还是庙,冷落的圣像依然是神。 在前端开发中我们或许想定时做一些操作 可以使用一个setInterval函数去做 123456// 定时控制台打印rubensetInterval(function () { console.log("ruben");}, 1000);// 定时控制台打印achao,注意这里是使用字符串形式写法setInterval('console.log("achao");', 1000); 可以打开控制台看到效果
springboot单元测试
每个圣人都有过去,每个罪人都有未来。 ――王尔德 我们在开发中经常会进行测试,如果是需要springboot环境,我们就可以使用spring-boot-starter-test 引入依赖 1234567891011<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </...
vue路由NavigationDuplicated错误
有志者,事竟成,破釜沉舟,百二秦关终属楚;苦心人,天不负,卧薪尝胆,三千越甲可吞吴。——蒲松龄 如果遇到了Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location异常 可以在router里配置一下 1234567891011121314151617181920import Vue from 'vue'import Router from 'vue-router'// 解决路由重复问题const originalPush = Router.prototype.pushRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err)}Vue.use(Router)export default new Router({...
实用避免空指针的工具类
一星陨落,黯淡不了星空灿烂;一花凋零,荒芜不了整个春天。——巴尔扎克 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495package com.ruben.utils;import com.ruben.pojo.User;import org.thymeleaf.expression.Lists;import sun.reflect.misc.ReflectUtil;import java.math.BigDecimal;import java.util.ArrayList;import java.util.List;import java.util.Optional;import java.util.concurrent.atomic.AtomicReference;...
elementUI隐藏组件
追求使你充实,成功和失败都是伴奏。——史铁生 关于ElementUI相信大家只要看过我这篇博客,都能有一定的了解 今天聊聊ElementUI官方文档都找不到的一个隐藏组件 那便是滚动条el-scrollbar 我们在开发中可能会用到数据量稍微多一点点的情况 例如我这里写的一个v-for 123456789<div style="width: 20%"> <div v-for="(item, i) in tableData" :key="i"> <div v-text="item.name"></div> <div v-text="item.name"></div> <div v-text="item.name"></div> <div v-text="item.name"></div> &...
js打字机动画效果实现
坦白使人心地轻松的妙药。——西塞罗 实现打字机效果 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <style> ...
set取交集、并集、差集
蜡烛的美是绝唱的美,它以自焚的痛苦将自己化为光和热,照亮了别人。——鲁迅 123456789101112131415HashSet<String> hashSet = new HashSet<>(Arrays.asList("0", "1", "2"));HashSet<String> hashSet2 = new HashSet<>(Arrays.asList("1", "2", "3"));// 取交集hashSet.retainAll(hashSet2);hashSet.forEach(System.out::println);System.out.println();HashSet<String> hashSet3 = new HashSet<>(Arrays.asList("0", "1", "2"));// 取并集h...
mybatis-plus基本使用
如果一个人不知道他要驶向哪个码头,那么任何风都不会是顺风。——小塞涅卡 上回我们写到封装了axios的工具类 今天我把OSS上传文件接了,可以去项目目录自取 前端项目:https://gitee.com/VampireAchao/my-vue-app.git 后端项目:https://gitee.com/VampireAchao/simple-springboot.git 传统代码以点到为止,所以这里就不再多聊OSS,想了解可以看这篇博客 然后我们聊聊mybatis-plus的基本使用 首先引入依赖,这个没什么好说的 12345<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.1.0</version></dependency> 然后我们按照之前创的表去对应新建一个DO 因为之前我们的表结构为这样【T...
Streamのlist链表转换
如果人生有也能有第二版,我将会如何认真地修改校对!——克莱尔 直接上代码! 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970package com.ruben;/** * @ClassName: ListNodeDemo * @Date: 2020/11/21 0021 00:06 * @Description: */import java.util.Comparator;import java.util.List;import java.util.concurrent.atomic.AtomicInteger;import java.util.function.Function;import java.util.stream.Collectors;import java.util.stream.Stream;/** * @ClassName: ListNodeDe...
