2026/1/17 23:40:26
网站建设
项目流程
网站行高,中专网站建设课程,网站服务是指,别人做的网站打不开所谓的全注解开发就是不再使用spring配置文件了。写一个配置类来代替配置文件。
package com.powernode.spring6.config;import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springfra…所谓的全注解开发就是不再使用spring配置文件了。写一个配置类来代替配置文件。packagecom.powernode.spring6.config;importorg.springframework.context.annotation.ComponentScan;importorg.springframework.context.annotation.ComponentScans;importorg.springframework.context.annotation.Configuration;ConfigurationComponentScan({com.powernode.spring6.dao,com.powernode.spring6.service})publicclassSpring6Configuration{}编写测试程序不再new ClassPathXmlApplicationContext()对象了。TestpublicvoidtestNoXml(){ApplicationContextapplicationContextnewAnnotationConfigApplicationContext(Spring6Configuration.class);UserServiceuserServiceapplicationContext.getBean(userService,UserService.class);userService.save();}