springBoot
文章平均质量分 71
code_agent
代码特工
展开
-
@Cacheable的使用
一、配置 1.配置redis 默认是有配置redis的情况会使用redis作为缓存。 2.配置Cache @Configuration // 使用redis作为cache的缓存,前提是要配置redis @ConditionalOnBean(RedisConfiguration.class) public class CacheConfiguration { @Resource private RedisConnectionFactory factory; @Resource原创 2021-06-10 18:45:24 · 1755 阅读 · 0 评论 -
springboot集成websocket
springboot集成websocket 1.pom添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> </dependency> 2.配置文件: server: port: 8885 3.添加配置类 import org.spri原创 2020-10-29 17:26:33 · 130 阅读 · 0 评论 -
@async注解的使用
异步调用 1.使用: springboot中的启动类中添加注解**@EnableAsync**来开启异步调用; 在需要异步执行的方法上添加**@Async(“taskExecutor”)**注解进行标注; 类或者方法中都可使用@Async注解,(类上标有该注解表示类中方法都是异步方法); @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @inter原创 2021-06-03 21:52:59 · 1563 阅读 · 0 评论