- 博客(4)
- 收藏
- 关注
原创 aop实现切换数据源
如果想放在mapper层面上,注意不能和mybatisPlus搭配使用,因为使用的mp自带的方法,根本不会进去mapper接口层,所以也进不了Before。@Target注解中ElementType.METHOD是指注解在方法上使用ElementType.TYPE是类上。@Before(“@annotation(myadmin)”)//方法前执行。@Before(“@within(myadmin)”)//类前执行。这个@annotation注解是方法前执行加的。这个@within注解是类前执行加的。
2023-03-23 00:06:58
207
转载 springboot切换数据源 纯代码
DataSourceUtil.java配置类代码下面。DynamicDataSource.java代码下面。DataSourceConfig.java配置类。我写这个博客只是怕作者删除文档 我找不到原链接。application.yml下面代码。controller代码下面。如果爆数据路url之类的问题。
2023-03-21 20:39:43
136
原创 两个对象的 hashCode() 相同,则 equals() 也一定为 true,对吗?
今天看到了这个问题,本来看到的答案是不对,两个对象的 hashCode() 相同,equals() 不一定 true。代码示例:String str1 = "通话";String str2 = "重地";System. out. println(String. format("str1:%d | str2:%d", str1. hashCode(),str2. hashCode()));System. out. println(str1. equals(str2));执行的结果:str1:
2020-09-24 09:42:21
562
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人