在一个弹簧启动容器中运行多个Web应用程序 [英] Run multiple web apps in one spring boot container

查看:205
本文介绍了在一个弹簧启动容器中运行多个Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够让多个网络应用共享域项目并在不同的contextPaths下运行。

I would like to be able to have multiple web apps sharing a domain project and running under different contextPaths.

通过在春天设置server.contextPath = / webshop启动应用程序我不需要为所有RequestMappings添加前缀。

By setting server.contextPath=/webshop in a spring boot app I dont need to prefix all the RequestMappings.

我希望网店,管理员和主页共享一个包含所有实体和公共域的公共域项目服务。

I would like the webshop, admin, and main page to share a common domain project which contains all the entities and common services.

可能有类似的东西?

public static void main(String[] args) {
    new SpringApplicationBuilder(Domain.class)
        .showBanner(false)
        .child(Admin.class, Webshop.class)
        .run(args);
}

我的问题是如何使用通用域模型启动Spring启动应用程序,然后是几个独立的web应用程序与独特的contextPaths?

My problem is how do I start a spring boot app with a common domain model, and then a couple of stand alone web apps with unique contextPaths?

推荐答案

像这样举例:

public static void main(String[] args) {
    start(Admin.class, Webshop.class).run(args);
    start(Another.class).properties("server.port=${other.port:9000}").run(args);
}

private static SpringApplicationBuilder start(Class<?>... sources) {
    return new SpringApplicationBuilder(Domain.class)
        .showBanner(false)
        .child(sources);
}

它会在不同的端口启动两个应用程序。

It would start two apps on different ports.

这篇关于在一个弹簧启动容器中运行多个Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆