main方法调用spring的service
将业务层类配置到Spring中:
<bean id="customerService" class="cn.itcast.crm.service.impl.CustomerServiceImpl"> </bean>
Spring的方式进行操作:
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
CustomerService customerService = (CustomerService) applicationContext.getBean("customerService");
customerService.save(customer);
main方法调用spring的dao service方法
public static void main(String[] args) {
ApplicationContext context = new
ClassPathXmlApplicationContext("ApplicationContext.xml");
System.out.println("aaa");
// ServiceReportService service = (ServiceReportService)context.getBean("serviceReportService");
}
以上为个人经验,希望能给大家一个参考,也希望大家多多支持靠谱客。
最后
以上就是轻松玉米最近收集整理的关于java的main方法中调用spring的service方式的全部内容,更多相关java内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复