While deploying more than one Spring Boot application in a single Tomcat server means showing exception. How to solve this?

前端 未结 3 746
孤街浪徒
孤街浪徒 2021-01-04 07:48

I am using Spring Boot in my Java application, and to deployment used Tomcat 7. I was trying to deploy multiple Spring Boot projects in the same server it showing exceptions

相关标签:
3条回答
  • 2021-01-04 08:32

    I think the jmx doesn't allow 2 beans with the same objectName to be created. You have 2 options.

    1. Turn off JMX and try to start it again.
    2. Change the name of the bean environmentManager(and any other duplicated bean) on one of the applications you are putting in the same container
    0 讨论(0)
  • 2021-01-04 08:33

    In my case, we need to have two of the same application online during updates before cutting over sessions to maintain 100% uptime. In this case, you cannot just specify a unique name (unless you update it for each potential deployment). Instead, I disabled jmx with the following setting in my application.yml file for all profiles:

    spring:
      jmx:
        enabled: false
    
    0 讨论(0)
  • 2021-01-04 08:43

    I think what happens when you deploy multiple Spring Boot applications is those apps try to register to jmx on the same jvm using the same name.

    1. Check this issue for the solution https://github.com/spring-cloud/spring-cloud-config/issues/118

    2. Copy-paste from DavidBiesack's solution (regarding application.properties or application.yaml)

    I was able to solve this by defining the following in my application.properties

    spring.application.name=my-app-name
    spring.jmx.default-domain=my-app-name
    

    Or for application.yaml:

    spring:
      application:
        name: my-app-name
      jmx:
        default-domain: my-app-name
    
    0 讨论(0)
提交回复
热议问题