# springboot **Repository Path**: yanshaohui/springboot ## Basic Information - **Project Name**: springboot - **Description**: springboot技术验证及总结 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-06-27 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #springboot **1. springboot-2db: 配置多个数据源测试,依赖jpa,使用swagger2验证接口** - 数据库rds(mysql5.7) + H2 - 发布到阿里ECS http://47.94.231.219:8081/swagger-ui.html **2. springboot-mybatis: 配置用注解方式访问mybatis,使用swagger2验证接口** - 数据库rds(mysql5.7) - 发布到阿里ECS http://47.94.231.219:8082/swagger-ui.html **3. springboot-groovy: 与(2)相同,改为groovy实现** - 数据库rds(mysql5.7) - 6月29日,增加缓存注解 > 缓存注解采坑笔记: 1. 增删改返回对象类型必须与查询结果对象一致,才能使用同一个缓存。因为mybatis的update/insert/delete返回非对象,故增加缓存服务层,变换dao层操作的返回值 2. 缓存加在接口上没有起效,移到实现类上 3. 希望同一个表加多个缓存的努力会带来复杂性:findByName/findAddressByName返回结果一个是实体,一个只是String。虽然试图用cacheNames区分为2个缓存, 但update方法只能有一个返回值,造成CachePut刷新缓存后缓存内容类型可能混乱(缓存更新为实体,再findAddressByName时走缓存,类型无法转换为String)。 以代码为例,当执行过update或insert后,执行findAddressByName会失败,因为缓存中这个Key放的是AddressEntity。 4. 注解意义: - Cacheable:根据方法返回值创建缓存,缓存存在时方法不执行 - CachePut:根据方法返回值创建缓存,缓存存在时方法也会执行 - CacheEvict:删除缓存,只根据key删除,所以不关心方法返回值。 5. key对应的是函数参数 **4. springboot-sso: 与springcloud-auth2为服务端的一个SSO登录客户端。 > 踩坑笔记: 1. 服务端和客户端不能同时在一台机器上测试,cookie会互相影响,却报告csrf被篡改。修改了springcloud-auth2的server.contextPath才解决