java普通类如何调用Spring的Service层?

首先在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");
上一篇:ADO.NET Entity Framework(EF)


下一篇:REST-framework快速构建API--生成Swagger接口文档