在main方法中请求spring管理的service

来源:互联网 发布:知乎成都最好的研究所 编辑:程序博客网 时间:2024/06/01 01:33

ApplicationContext context = new ClassPathXmlApplicationContext("classpath:appContext.xml");
  
  UserAction action = new UserAction();
  action.setUserServiceImpl((UserService)context.getBean("userServiceImpl"));

action.getUserServiceImpl().addUser(user);

 

原创粉丝点击