spring aop 源码分析(三) @Scope注解创建代理对象
一.源码环境的搭建:
@Component
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_SINGLETON,proxyMode = ScopedProxyMode.TARGET_CLASS)
public class MyMath implements Calc{
public Integer add(int num1,int num2){
return num1+num2;
}
}
@Configuration
@ComponentScan("com.yang.xiao.hui.aop")
public class App
{
public static void main( String[] args )
{
ApplicationContext ctx = new AnnotationConfigApplicationContext(App.class);
MyMath myMath = (MyMath)ctx.getBean("myMath");
System.out.println(myMath.getClass());
System.out.println(ctx.getBean("scopedTarget.myMath").getClass());
}
}

![spring aop 源码分析(三) @Scope注解创建代理对象
[编程语言教程]](https://www.zixueka.com/wp-content/uploads/2024/01/1706715297-1784f5dd5080f8a.jpg)
