springboot如何引入自定义spring.xml文件:详见
一、spring boot推荐使用注解方式进行配置:写类,@Configuration @Bean 配置类(等价于spring.xml)
二、编写一个配置类AppConfig.java
package org.yq.HelloWorld.config;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.yq.HelloWorld.service.StudentService;
//配置类
@Configuration
public class AppConfig {
@Bean
public StudentService stuService(){//<bean id="xxxxxxxxxxxxx">
StudentService stuService = new StudentService();
// StudentDao stuDao = new StudentDao() ;
// stuService.setStudentDao(stuDao);
return stuService;//返回值 <bean class="xxxxxxxxxxxxx">
}
}