软件编程
位置:首页>> 软件编程>> java编程>> java的main方法中调用spring的service方式

java的main方法中调用spring的service方式

作者:jovi_zhao  发布时间:2023-03-29 00:12:16 

标签:java,main方法,spring,service

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");
   }

来源:https://blog.csdn.net/jovi_zhao/article/details/83010881

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com