AOP的相关代理
在沒有使用aop的情況下 :class cn.dym.service.impl.UserServiceImpl當(dāng)使用了aop的情況下:class com.sun.proxy.$Proxy19jdk代理所產(chǎn)生的一個動態(tài)代理類,當(dāng)被代理的類實現(xiàn)了接口會默認使用jdk代理
class cn.dym.service.impl.UserServiceImpl$$EnhancerBySpringCGLIB$$f281cf64cglib代理所所產(chǎn)生的一個動態(tài)代理類,當(dāng)被代理的類沒有實現(xiàn)接口就會使用cglib代理
package cn.dym.tests;import cn.dym.service.IUserService; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext;public class SpringTest {@Testpublic void test() throws Exception {ClassPathXmlApplicationContext ioc=new ClassPathXmlApplicationContext("classpath:/spring.xml");IUserService bean = (IUserService) ioc.getBean(IUserService.class);System.out.println(bean.getClass());} }
package cn.dym.tests;import cn.dym.service.IUserService; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext;public class SpringTest {@Testpublic void test() throws Exception {ClassPathXmlApplicationContext ioc=new ClassPathXmlApplicationContext("classpath:/spring.xml");IUserService bean = (IUserService) ioc.getBean(IUserService.class);System.out.println(bean.getClass());} }
?
bean的獲取方式:要么通過接口去獲取;要么通過名字去獲取
總結(jié)
- 上一篇: Sharding Sphere 读写分离
- 下一篇: AOP切入点表达式 ——within表达