创建自动配置类
作者:互联网
基于《@SpringBootApplication 标注非引导类》例子,
1、、将App标记为@EnableAutoConfiguration,并作为App.run方法的首参。
@EnableAutoConfiguration public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } }
2、WebConfiguration
@Configuration public class WebConfiguration { ... }
3、创建自动装配类WebAutoConfiguration,并使用@Import导入WebConfiguration
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration @Import(WebConfiguration.class) public class WebAutoConfiguration { }
4、在项目src/main/resources目录下新建META-INF/spring.factories资源,并配置WebAutoConfiguration类:
#自动装配 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.ebc.WebAutoConfiguration
标签:WebAutoConfiguration,WebConfiguration,创建,App,配置,springframework,public,自动,class 来源: https://www.cnblogs.com/yaoyuan2/p/11741462.html