标签:target get 资源 framework 创建 pre html autoconf 自动装配
基于《@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
标签:target get 资源 framework 创建 pre html autoconf 自动装配
原文地址:https://www.cnblogs.com/yaoyuan2/p/11741462.html