http://www.oschina.net/translate/comparative_analysis_between_spring_aop_and_aspectj

 

 

spring使用注解生成bean的时候, 生成bean的构造方法执行一次, 但是在使用aspectj进行通知的加入后, 生成bean时构造方法执行2遍, 为什么????

 

 

@Service
public class TestService {
    private static String id = "1";
    @Autowired
    @Qualifier("testDao")
    private TestDao testDao;
    TestService(){
     System.out.println("创建TestService"+(id+"9"));
 }
    TestService(String id1){
        id = id1;
        System.out.println("创建testService,通过有参构造");
    }
    public void save(){
        testDao.save();
    }
    public void change(){
        System.out.println("change方法"+">>>>>"+id);
    }
    
}

 

相关文章:

  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-09
  • 2021-07-18
  • 2021-12-30
  • 2022-01-12
  • 2021-09-13
  • 2021-08-23
  • 2022-02-28
相关资源
相似解决方案