小编Ale*_*lla的帖子

创建具有多个子上下文的spring启动应用程序

我正在尝试使用具有分层应用程序上下文的spring boot创建应用程序.我目前的主要方法如下:

public static void main(String[] args) {
    new SpringApplicationBuilder(TestApplication.class)
            .child(AuditServiceConfiguration.class).web(true)
            .child(TaskServiceConfiguration.class).web(true)
            .run(args);
}
Run Code Online (Sandbox Code Playgroud)

并且两个子配置注释为:

@EnableAutoConfiguration
@Configuration
Run Code Online (Sandbox Code Playgroud)

我们的想法是让父上下文包含所有公共bean和每个子上下文,以便在与其兄弟姐妹隔离时运行自己的MVC.

不幸的是,当我运行上面的命令时,只会初始化并启动最后一个子上下文.

任何指向正确方向的人都会非常感激.

问候,

亚历山德罗

spring hierarchical applicationcontext spring-boot

13
推荐指数
1
解决办法
6484
查看次数