在一个 Tomcat 上运行多个 Spring-boot 应用程序 [英] Multiple Spring-boot applications running on one Tomcat

查看:43
本文介绍了在一个 Tomcat 上运行多个 Spring-boot 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在一个 Tomcat 上运行两个(或更多)Spring-boot 应用程序吗?

Can I have two (or more) Spring-boot applications running on one Tomcat?

我有两个应用程序打包为 war 文件,我想在一台 Tomcat 服务器上运行它们.但是,当我部署它们时,出现以下异常:

I have two applications packaged as war files and I would like to run them on one Tomcat server. However, when I deploy them, I get the following exception:

org.springframework.jmx.export.UnableToRegisterMBeanException: 
    Unable to register MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean@2361d8ee] with key 'dumpEndpoint'; 
    nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=dumpEndpoint

每个 Spring-boot 应用程序注册的默认端点(如/health 等)发生冲突.是否有一些解决方法或无法实现此设置?

The default endpoints that every Spring-boot application registers (like /health etc.) clash. Is there some workaround for this or is not possible to achieve this setup?

感谢您的任何回复!

推荐答案

As Spring Boot 参考 说:

如果您的应用程序包含多个 Spring ApplicationContext,您可能会发现名称冲突.要解决此问题,您可以将 endpoints.jmx.uniqueNames 属性设置为 true,以便 MBean 名称始终唯一.

If your application contains more than one Spring ApplicationContext you may find that names clash. To solve this problem you can set the endpoints.jmx.uniqueNames property to true so that MBean names are always unique.

endpoints.jmx.domain=myapp
endpoints.jmx.uniqueNames=true

这篇关于在一个 Tomcat 上运行多个 Spring-boot 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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