首先在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");