随笔分类 -  Spring

摘要:##自定义过滤标签 import org.apache.commons.beanutils.PropertyUtils; import javax.validation.Constraint; import javax.validation.ConstraintValidator; import j 阅读全文
posted @ 2021-08-11 19:39 是谁扭曲了时空 阅读(1088) 评论(0) 推荐(2) 编辑
摘要:引入 使用 阅读全文
posted @ 2020-04-20 10:15 是谁扭曲了时空 阅读(171) 评论(0) 推荐(0) 编辑
摘要:Spring提供的 编译期(Idea\Eclipse编译时检查,需设置开启) Null safety检查 :字段可以为空 :字段不能为空 : 包级别,参数和返回值非null :包级别,字段默认非空 package info.java 放在需检查的包路径下 阅读全文
posted @ 2020-02-08 11:14 是谁扭曲了时空 阅读(2645) 评论(0) 推荐(0) 编辑
摘要:TargetSource(目标源)是被代理的target(目标对象)实例的来源。TargetSource被用于获取当前MethodInvocation(方法调用)所需要的target(目标对象),这个target通过反射的方式被调用(如:method.invode(target,args))。 换句 阅读全文
posted @ 2020-01-21 19:45 是谁扭曲了时空 阅读(965) 评论(0) 推荐(0) 编辑
摘要:HSDB:HotSpot Debugger Jvm自带工具,用于查看JVM运行时的状态 1、断点 断点查看代理类名,或者打印输出 2、查看进程ID jps命令查看当前程序的进程ID值 3、启动HSDB 如果HSDB启动报错:UnsatisfiedLinkError sawindbg.dll 再jdk 阅读全文
posted @ 2020-01-20 14:03 是谁扭曲了时空 阅读(369) 评论(0) 推荐(0) 编辑
摘要:使用方法 源码跟踪: springframework.web--》WebDataBinder-》validate springframework validation RequestResponseBodyMethodProcessor--》resolveArgument--》validateIfA 阅读全文
posted @ 2019-11-12 13:46 是谁扭曲了时空 阅读(2382) 评论(0) 推荐(0) 编辑
摘要:Spring字符串占位符替换 import org.springframework.util.PropertyPlaceholderHelper; import java.util.Properties; public class PlaceholderUtil { private static P 阅读全文
posted @ 2019-11-11 11:28 是谁扭曲了时空 阅读(815) 评论(0) 推荐(0) 编辑
摘要:写在前面 expose-proxy。为是否暴露当前代理对象为ThreadLocal模式。 SpringAOP对于最外层的函数只拦截public方法,不拦截protected和private方法(后续讲解),另外不会对最外层的public方法内部调用的其他方法也进行拦截,即只停留于代理对象所调用的方法 阅读全文
posted @ 2019-10-28 11:02 是谁扭曲了时空 阅读(433) 评论(0) 推荐(0) 编辑
摘要:在传统的基于代理类的AOP实现中,每个代理都是通过ProxyFactoryBean织入切面代理,在实际开发中,非常多的Bean每个都配置ProxyFactoryBean开发维护量巨大。解决方案:自动创建代理 BeanNameAutoProxyCreator 根据Bean名称创建代理 DefaultA 阅读全文
posted @ 2019-10-26 10:28 是谁扭曲了时空 阅读(950) 评论(0) 推荐(0) 编辑
摘要:原理:观察者模式 spring的事件监听有三个部分组成,事件(ApplicationEvent)、监听器(ApplicationListener)和事件发布操作。 事件 事件类需要继承ApplicationEvent,代码如下: public class HelloEvent extends App 阅读全文
posted @ 2019-06-05 21:36 是谁扭曲了时空 阅读(18672) 评论(0) 推荐(7) 编辑
摘要:Application下抽象子类ApplicationContextEvent的下面有4个已经实现好的事件 同样,这四个事件都继承了ApplicationEvent,如果我们想自定义事件,也可以通过继承ApplicationEvent来实现 使用示例: 1.新建一个MyEvent的类,继承Appli 阅读全文
posted @ 2019-04-20 18:47 是谁扭曲了时空 阅读(423) 评论(0) 推荐(0) 编辑
摘要:Environment 环境在容器中是一个抽象的集合,是指应用环境的2个方面: profiles和 properties. profile 配置是一个被命名的,bean定义的逻辑组,这些bean只有在给定的profile配置激活时才会注册到容器。不管是XML还是注解,Beans都有可能指派给prof 阅读全文
posted @ 2019-04-19 15:42 是谁扭曲了时空 阅读(2968) 评论(0) 推荐(0) 编辑
摘要:@Import 注解可以普通类导入到 IoC容器中。 想要让一个普通类接受 Spring 容器管理,有以下方法 使用 @Bean 注解 使用 @Controller @Service @Repository @Component 注解标注该类,然后再使用 @ComponentScan 扫描包 @Im 阅读全文
posted @ 2019-04-05 22:22 是谁扭曲了时空 阅读(763) 评论(0) 推荐(0) 编辑
摘要:Cglib动态代理实现方式 我们先通过一个demo看一下Cglib是如何实现动态代理的。 首先定义个服务类,有两个方法并且其中一个方法用final来修饰。 public class PersonService { public PersonService() { System.out.println 阅读全文
posted @ 2019-03-25 22:00 是谁扭曲了时空 阅读(2488) 评论(0) 推荐(1) 编辑
摘要:1、获取 applicationContext,通过ApplicationAware自动注入 2、getBeansOfType、getBeanNamesForType //key位 beanName,value为bean Map<String, Interface> result = applica 阅读全文
posted @ 2019-01-21 21:56 是谁扭曲了时空 阅读(12602) 评论(2) 推荐(0) 编辑
摘要:Spring官方文档,用的版本为4.3.11版本。 一、引用官方文档 2.2.1核心集装箱 所述核心容器由以下部分组成spring-core, spring-beans,spring-context,spring-context-support,和spring-expression(弹簧表达式语言) 阅读全文
posted @ 2018-12-11 13:43 是谁扭曲了时空 阅读(381) 评论(0) 推荐(0) 编辑
摘要:本着“不写单元测试的程序员不是好程序员”原则,我在坚持写着单元测试,不敢说所有的Java web应用都基于Spring,但至少一半以上都是基于Spring的。 发现通过Spring进行bean管理后,做测试会有各种不足, 例如,很多人做单元测试的时候,还要在Before方法中,初始化Spring容器 阅读全文
posted @ 2018-12-11 11:41 是谁扭曲了时空 阅读(1407) 评论(0) 推荐(0) 编辑
摘要:现如今有许多个可用的 AOP 库,使用这些库需要能够回答以下问题: 是否与现有的或新的应用程序兼容? 在哪里可以使用 AOP ? 如何迅速与应用程序集成? 性能开销是多少? 在本文中,我们将回答这些问题并介绍 Spring AOP 和 AspectJ ——两个最受欢迎的 AOP 框架。 AOP 概念 阅读全文
posted @ 2018-11-26 10:13 是谁扭曲了时空 阅读(351) 评论(0) 推荐(0) 编辑
摘要:@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE)这个是说在每次注入的时候回自动创建一个新的bean实例 @Scope(value=ConfigurableBeanFactory.SCOPE_SINGLETON)单例模式,在整个应用中只能创建一 阅读全文
posted @ 2018-11-18 20:09 是谁扭曲了时空 阅读(1867) 评论(0) 推荐(0) 编辑