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

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

问题描述

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



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

  org.springframework.jmx.export.UnableToRegisterMBeanException:无法注册使用键'dumpEndpoint'的MBean [org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean@2361d8ee];嵌套异常是javax.management.InstanceAlreadyExistsException:org.springframework.boot:type = Endpoint,name = dumpEndpoint 

每个Spring引导应用程序注册的默认端点(如/ health等)冲突。是否有一些解决方法为此或不可能实现此设置?



感谢您的任何回应!

解决方案

As Spring引导参考说:


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




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


Can I have two (or more) Spring-boot applications running on one 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

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?

Thank you for any responses!

解决方案

As Spring Boot Reference says:

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天全站免登陆