首先在Service层上面添加 @Service("myService")

然后,在main方法中调用,String[]中为配置文件,如下所示:

 ApplicationContext applicationContext=new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml","spring-mvc.xml","spring-mybatis.xml"});
 MyService myService=(MyService)applicationContext.getBean("myService");

 

相关文章:

  • 2022-12-23
  • 2021-09-29
  • 2022-03-04
  • 2021-06-01
  • 2022-12-23
  • 2021-11-06
  • 2021-04-17
  • 2021-12-24
猜你喜欢
  • 2021-09-11
  • 2022-12-23
  • 2021-12-22
  • 2022-01-13
  • 2021-10-31
  • 2022-12-23
  • 2021-10-14
相关资源
相似解决方案