在没有使用aop的情况下 :class cn.dym.service.impl.UserServiceImpl
当使用了aop的情况下:
class com.sun.proxy.$Proxy19
jdk代理所产生的一个动态代理类,当被代理的类实现了接口会默认使用jdk代理
class cn.dym.service.impl.UserServiceImpl$$EnhancerBySpringCGLIB$$f281cf64
cglib代理所所产生的一个动态代理类,当被代理的类没有实现接口就会使用cglib代理
package cn.dym.tests;
import cn.dym.service.IUserService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringTest {
@Test
public void test() throws Exception {
ClassPathXmlApplicationContext ioc=new ClassPathXmlApplicationContext("classpath:/spring.xml");
IUserService bean = (IUserService) ioc.getBean(IUserService.class);
System.out.println(bean.getClass());
}
}
bean的获取方式:要么通过接口去获取;要么通过名字去获取