Spring Boot的特性:SpringApplication流式构建API

时间:2020-07-12 11:35:34   收藏:0   阅读:71
[

23.4. 流式构建API

如果需要创建一个分层的ApplicationContext(多个具有父子关系的上下文),或只是喜欢使用流式(fluent)构建API,那你可以使用SpringApplicationBuilder。 SpringApplicationBuilder允许你以链式方式调用多个方法,包括parent和child方法,这样就可以创建多层次结构,例如:

new SpringApplicationBuilder()
        .sources(Parent.class)
        .child(Application.class)
        .bannerMode(Banner.Mode.OFF)
        .run(args);

注:创建ApplicationContext层次时有些限制,比如,Web组件必须包含在子上下文中,并且父上下文和子上下文使用相同的Environment,具体参考SpringApplicationBuilder javadoc

?

本文来自:Spring Boot的特性:SpringApplication流式构建API

]
  • ??本文标题:Spring Boot的特性:SpringApplication流式构建API - Break易站
    转载请保留页面地址:https://www.breakyizhan.com/springboot/3251.html

    原文:https://www.cnblogs.com/breakyizhan/p/13287181.html

    评论(0
    © 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
    打开技术之扣,分享程序人生!