SpringBoot
国际庄
这个作者很懒,什么都没留下…
展开
-
SpringBoot中创建交换器、队列和绑定关系
@AutowiredAmqpAdmin amqpAdmin;@Testpublic void test(){ amqpAdmin.declareExchange(new DirectExchange("demo.exchange")); amqpAdmin.declareQueue(new Queue("demo.queue",true)); amqpAdmin.declareBinding(new Binding("demo.queue",Binding.DestinationType.QUE原创 2020-08-26 21:47:12 · 485 阅读 · 1 评论 -
SpringBoot中使用RabbiMQ
1、@Servicepublic class BookService { @RabbitListener(queues = "aaa.demo") public void receive (Book book){ System.out.println("收到消息:" + book); }}2、@EnableRabbit3、@RabbitListener(queues = "aaa")public void receive(Message message){ System.ou原创 2020-08-24 23:22:58 · 80 阅读 · 0 评论 -
SpringBoot整合RabbitMQ
1、2、spring.rabbitmq.host=192.168.124.15spring.rabbitmq.username=guestspring.rabbitmq.password=guest3、@AutowiredRabbitTemplate rabbitTemplate;@Testpublic void contextLoads() { Map<String,Object> map = new HashMap<>(); map.put("msg",原创 2020-08-23 17:45:59 · 170 阅读 · 0 评论 -
SpringBoot中使用定时任务
1、@Servicepublic class ScheduledService { //second, minute, hour, day of month, month, and day of week. @Scheduled(cron = "0 * * * * MON-SAT") public void test(){ System.out.println("test..."); }}2、@EnableScheduling //开启基于注解的定时任务@SpringBootApp原创 2020-08-08 21:17:07 · 110 阅读 · 0 评论 -
SpringBoot中异步任务的使用
1、@Servicepublic class AsyncService { @Async //这是一个异步方法 public void test(){ try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("数据处理中。。。"); }}2、@RestControllerpublic class AsyncCo原创 2020-08-08 09:52:27 · 126 阅读 · 0 评论 -
SpringBoot中使用Redis保存对象
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency>spring.redis.host=192.168.124.15@Autowired RedisTempla原创 2020-08-04 23:35:23 · 894 阅读 · 0 评论