随笔分类 -  spring

Spring Security Oauth2.0 知识点总结
摘要:Oauth2.0部分 AuthorizationServerConfigurerAdapter 授权服务器核心配置类 @EnableAuthorizationServer 启用授权服务器 TokenStore 令牌存储 AuthorizationServerTokenServices 令牌服务 为什 阅读全文

posted @ 2022-11-12 23:53 zhangyukun 阅读(567) 评论(0) 推荐(1)

Spring Security 知识点总结
摘要:Security部分 WebSecurityConfigurerAdapter security 配置的核心类在这里配置权限等信息 authentication authentication 是认证(登陆) authorization authorization 指的是授权(获取权限) 所有post 阅读全文

posted @ 2022-11-10 01:34 zhangyukun 阅读(316) 评论(0) 推荐(0)

spring生命周期监听接口概述
摘要:1 ApplicationContextInitializer 容器初始化之前执行 2 ApplicationListener 在容器的各个生命周期执行 ,通过事件区分,第一次执行在 SpringApplicationRunListener.starting 之前,最后一次执行在 SpringApp 阅读全文

posted @ 2022-09-09 00:31 zhangyukun 阅读(129) 评论(0) 推荐(0)

aspectj this target within 区别
摘要:首先他们三个都匹配一个明确的类型 里面的所有方法 不能带有方法,包名等通配符 只能写成 within(包名.类名格式) 假设有一下继承关系 有一个接口 A ,这个接口有一个实现类A1 A1 有两子类 B,C 1 within 只能匹配指定类型不能匹配子类,并且对比类型是目标类型,target 和 t 阅读全文

posted @ 2022-07-17 02:02 zhangyukun 阅读(148) 评论(0) 推荐(0)

spring aspectj 切入点表达式详解
摘要:1 切入点表达式 切人点表达式可以按照 修饰方式分为注解和非注解分成2类,带有@的是匹配注解的,没有代@的是匹配非注解的 within 用于限定类型,args 用于限定参数,target 指的限定类型和子类,this 指的调用者类型 1 execution 匹配 指定修饰符 指定返回值类型 指定包 阅读全文

posted @ 2022-07-16 14:44 zhangyukun 阅读(440) 评论(0) 推荐(0)

JDK 动态代理 和 cgLib动态代理
摘要:1 spring 动态代理的一些说明 1 spring 5.0 默认使用的 代理方式 依旧是 jdk 动态代理(之前的版本也是) 2 springboot 2.X 开始 默认使用代理方式 cglib(springboot 2.X 默认使用 spring 5,给人的感觉是 spring 5.0 开始默 阅读全文

posted @ 2022-07-14 23:28 zhangyukun 阅读(310) 评论(0) 推荐(1)

spring cloud alibaba 基本用法
摘要:maven import 属性 <!--spring alibaba--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <ve 阅读全文

posted @ 2022-07-03 16:39 zhangyukun 阅读(208) 评论(0) 推荐(0)

spring cloud 集成和使用
摘要:说明: 父工程文件如下: spring boot 版本:2.6.8 spring cloud 版本:3.1.3 hystrix,停更以后没有最新版,所以用的:2.2.10.RELEASE 父工程 pom.xml 如下:所有子项目使用的依赖版本都在这里面 <?xml version="1.0" enc 阅读全文

posted @ 2022-06-29 22:30 zhangyukun 阅读(317) 评论(0) 推荐(0)

Caused by: java.lang.IllegalStateException: getWriter() has already been called for this response
摘要:异常堆栈:看着是一个响应流被再次使用 Caused by: java.lang.IllegalStateException: getWriter() has already been called for this response at org.apache.catalina.connector. 阅读全文

posted @ 2022-06-22 14:52 zhangyukun 阅读(412) 评论(0) 推荐(0)

Dubbo 测试用例 获取注册中心的其他服务
摘要:package com.xyebank.uk.user.service; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autow 阅读全文

posted @ 2022-04-12 17:49 zhangyukun 阅读(303) 评论(0) 推荐(0)

@Valid 注解 的验证之美 和验证类 异常捕获
摘要:@Valid 是JSR303 指定的标准 ,hibernate 对其做了实现。 <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> <version> 阅读全文

posted @ 2020-03-03 16:40 zhangyukun 阅读(580) 评论(0) 推荐(0)

spring boot java mail 导致程序无法启动问题
摘要:<!-- 发送邮件 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> mail: host: smt 阅读全文

posted @ 2020-02-03 15:32 zhangyukun 阅读(3479) 评论(0) 推荐(0)

@LoadBalanced 作用
摘要:作用 在使用 RestTemplate 的时候 如果 RestTemplate 上面有 这个注解,那么 这个 RestTemplate 调用的 远程地址,会走负载均衡器。 使用: @Bean @LoadBalanced RestTemplate restTemplate() { return new 阅读全文

posted @ 2020-01-09 14:52 zhangyukun 阅读(11158) 评论(0) 推荐(1)

spring boot 监听容器启动
摘要:/** * 在容器启动的时候 加载没问完成的消息重发 * @author zhangyukun * */ @Component @Slf4j public class LoadMessageListener implements ApplicationListener<ContextRefreshedEvent>,Ordered { @Autowired QueueMessageService q 阅读全文

posted @ 2019-10-16 11:58 zhangyukun 阅读(601) 评论(0) 推荐(0)

@Transactional 可以写在 Controller 方法上面了
摘要:上图 t1 掉用的service 没定义事物环境,但是 在 t1 上面定义了。 依旧可以 在 参数是5 的 时候 ,让 前面的操作级联回滚。 但是 我不建议这么用,除非特殊需求,正常来说事物根据在满足一致性的前提下,尽量避免长事物。 阅读全文

posted @ 2019-04-12 10:35 zhangyukun 阅读(4163) 评论(0) 推荐(0)

Transaction rolled back because it has been marked as rollback-only 原因 和解决方案
摘要:产生原因 , 1 serviceA 调用 serviceB 然后 B 抛出异常 ,B 所在的 事物 回滚,B 把当前可写 事物标记成 只读事物 , 2 如果 A 和B 是在 同一个事物环境,并且 A 抓了 B 抛出的异常,没有和 B 一起回滚, 3 然后 A 方法 完成,把当前事物 当成 写事物提交 阅读全文

posted @ 2019-03-27 17:38 zhangyukun 阅读(3898) 评论(0) 推荐(0)

spring boot 2 返回Date 格式化问题
摘要:以前 返回数据把Date 转成 long的时间毫秒数。现在是格式化成了字符串。 默认的结果:"createDate": "2018-09-06T10:04:25.000+0000", 可以通过 修改配 application.yml 来配置 Date 格式化: 结果:"createDate": "2 阅读全文

posted @ 2018-09-07 15:49 zhangyukun 阅读(1248) 评论(0) 推荐(0)

spring boot 项目 热启动 热部署
摘要:第一需要 spring-boot-devtools 依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</op 阅读全文

posted @ 2018-08-10 10:24 zhangyukun 阅读(252) 评论(0) 推荐(0)

spring 使用 maven profile
摘要:先看看 maven 定义 profile 的写法 <!-- profiles --> <profiles> <profile> <activation> <activeByDefault>true</activeByDefault> </activation> <id>dev</id> <prope 阅读全文

posted @ 2018-07-16 20:17 zhangyukun 阅读(2058) 评论(0) 推荐(0)

spring4 知识点
摘要:1 bean的 创建 1,直接在配置文件里面写一个带有@Bean注解的方法(返回值就是那个bean对象),(name等于 方法名) @Bean还可以写在枚举上面 2,使用 FactoryBean 接口(三个方法分别是创建,类型,单例),需要把它加入到spring 容器管理,@Component 或者 阅读全文

posted @ 2018-07-10 20:29 zhangyukun 阅读(143) 评论(0) 推荐(0)

导航