![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
springboot
qq_597950687
这个作者很懒,什么都没留下…
展开
-
Springboot在服务启动时运行加载的功能(如MQ)
@Componentpublic class ConsumerService implements CommandLineRunner {@Override public void run(String... args) throws Exception {//需要实现的功能代码}CommandLineRunner:实际应用中,我们会有在项目服务启动的时候就去加载一些数据或做一些事...原创 2018-07-04 14:20:33 · 2753 阅读 · 0 评论 -
Springboot:将Spring-Cache的缓存换为Redis
1、通过继承CachingConfigurerSupport,将Spring-Cache的缓存换为Redis 2、使用适合项目的key生成策略cacheKeyGeneratorpackage com.sinochem.erp.configuration.redis;import com.fasterxml.jackson.annotation.JsonAutoDetect;import ...转载 2018-07-04 15:58:07 · 1069 阅读 · 0 评论 -
Springboot:实现session共享
使用@Enableredishttpsession注解实现session共享所需依赖<!-- spring session --><dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session</artifactId&...原创 2018-07-04 16:04:16 · 510 阅读 · 0 评论 -
shiro+springboot:ShiroConfiguration,shiro配置
1.EhCacheManager EhCache缓存管理**********也可将shiro session存入redis中(后面dan)单独总结*****@Bean public EhCacheManager getEhCacheManager() { EhCacheManager em = new EhCacheManager(); em.se...原创 2018-07-27 15:04:39 · 3476 阅读 · 0 评论 -
shiro+springboot:MyFormAuthenticationFilter(自定义认证拦截)
在自定义认证拦截中,onAccessDenied 为入口,在onAccessDenied中调用自定义的认证方式(也可直接使用FormAuthenticationFilter的父类的认证方式,但是使用默认的无法自定义认证成功/失败后的操作)executeLogin(ServletRequest request, ServletResponse response) 认证方式onLogin...原创 2018-07-27 15:31:58 · 4824 阅读 · 0 评论 -
shiro+springboot:MyRealm(自定义Realm)
import com.sinochem.erp.common.entity.Permissions;import com.sinochem.erp.common.entity.Role;import com.sinochem.erp.common.entity.User;import com.sinochem.erp.common.exception.MoreUsersExceptio...原创 2018-07-27 15:40:11 · 1235 阅读 · 0 评论 -
shiro+springBoot+redis:将spring-chche缓存换为redis
1.通过继承CachingConfigurerSupport实现缓存转换import com.fasterxml.jackson.annotation.JsonAutoDetect;import com.fasterxml.jackson.annotation.PropertyAccessor;import com.fasterxml.jackson.databind.ObjectMa...原创 2018-07-27 16:35:04 · 378 阅读 · 0 评论 -
spring:缓存注解@Cacheable,@CacheEvict,@CachePut
Spring为我们提供了几个注解来支持Spring Cache。其核心主要是@Cacheable和@CacheEvict。使用@Cacheable标记的方法在执行后Spring Cache将缓存其返回结果,而使用@CacheEvict标记的方法会在方法执行前或者执行后移除Spring Cache中的某些元素。1. @Cacheable注解可写在方法或类上,表示该方法的返回值会存入缓存中。参...原创 2018-08-01 10:11:38 · 497 阅读 · 0 评论