- 博客(11)
- 资源 (1)
- 收藏
- 关注
原创 shardingJDBC配置-java多数据源分表
直接上代码pom文件配置<!-- jdbc --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> <exclusions> <
2022-05-17 15:27:34 837
原创 java使用redis接口访问频率限制
本文使用AOP与redis进行接口的访问频率限制,两个功能,可以限制两次接口访问间隔时间与几分钟内访问几次,比如,某接口3分钟内同一用户不能超过10次,并且两次访问间隔不能低于10S。废话不多说,上代码。@Target(ElementType.METHOD)@Retention(RetentionPolicy.RUNTIME)@Documented/** * one minutes request frequency is Fifty times, exceeding the wait fiv
2021-12-21 14:35:29 3367
原创 RabbitMq延时队列-死信方式处理延时任务
##队列绑定import org.springframework.amqp.core.*;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import java.util.HashMap;import java.util.Map;@Configurationpublic class RabbitMqConfig {
2020-08-20 20:07:52 221
原创 springBoot,使用jedis操作lua脚本实现分布式锁,兼容redis单点、集群、哨兵模式连接
@Configuration@ConditionalOnClass({GenericObjectPool.class})@Slf4jpublic class RedisConfig{ @Autowired RedisProperties redisProperties; @Value("${spring.redis.strategy}") private String strategy; @Bean public JedisSentinelPool j.
2020-08-19 11:07:30 413
原创 SpringBoot连接redis,支持单点、集群、哨兵模式自适应配置(二、redissonClient)
@Autowired RedisProperties redisProperties; /** * 哨兵模式自动装配 * * @return */ @Bean(destroyMethod = "shutdown") @ConditionalOnProperty(name="spring.redis.strategy", havingValue = "3") public RedissonClient redisson...
2020-08-19 10:54:19 2183
原创 SpringBoot连接redis,支持单点、集群、哨兵模式自适应配置(一、redisTemplate)
可以根据配置相应策略切换redis的模式@Autowired RedisProperties redisProperties; @Autowired @Value("${spring.redis.strategy}") private String strategy; /** * 连接池配置信息 */ @Bean public JedisPoolConfig jedisPoolConfig() { JedisP
2020-08-19 10:51:50 1542
原创 List的日期排序Collections.sort()
package test;import java.util.ArrayList;import java.util.Calendar;import java.util.Collections;import java.util.Date;import java.util.List;public class Test { public static void main(String[...
2019-09-19 16:49:29 1014
转载 多个图片链接打包成zip
public void download(HttpServletRequest request, HttpServletResponse response){ try { String downloadFilename = "中文.zip";//文件的名称 downloadFilename = UR...
2019-05-22 14:03:26 838
转载 spring MVC rmi配置
1.生产者配置<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.spring...
2019-04-16 11:21:44 314
转载 spring MVC dubbo 生产者和消费者配置
1.生产者配置<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:contex...
2019-04-16 11:00:45 992
转载 spring事务回滚相关
事务的作用就是为了保证用户的每一个操作都是可靠的,事务中的每一步操作都必须成功执行,只要有发生异常就回退到事务开始未进行操作的状态。 在实际项目中,使用事务是很简单的,在 Spring 项目中,一个 @Transactional 注解就可以解决。 1. 异常并没有被 “捕获” 到 这是个很常见的小坑,异常并没有被 “捕获” 到,导致事务并没有回滚。我们在业务层代码中,也许已...
2018-11-29 14:12:35 207
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人