本文介绍了javax.management.InstanceAlreadyExistsException:com.zaxxer.hikari:name = dataSource,type = HikariDataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何解决这个问题?哪个是最好的选择,以及如何做到这一点

How can i solve this problem? Which is best choice and how to do that

  1. 设置唯一的poolName
  2. 破坏先前的连接池
org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
11-Aug-2018 16:05:53.863 SEVERE [Catalina-startStop-1] org.apache.catalina.core.ContainerBase.startInternal A child container failed during start
 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[sss].StandardContext[]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at ..........
...............
......
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[sss].StandardContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        ... 6 more
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [HikariDataSource (HikariPool-2)] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
        at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625)
        at
..........................

org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 more
Caused by: javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
        at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
        at .................
............
        at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)`

推荐答案

有两种方法可以解决此问题.

There are two ways to solve this problem.

i.禁用jmx

ii.设置默认域和唯一名称(如果要启用jmx并具有同一应用程序的多个实例,则必须提供该名称)

ii. set default-domain and unique name( its required if you want to enable jmx and have multiple instance of same application)

要禁用jmx:

application.yml:

application.yml:

spring:
  jmx:
    enabled: false

或application.properties:

or application.properties:

spring.jmx.enabled= false

如果需要启用jmx,请设置以下属性.

application.yml:

application.yml:

spring:
  jmx:
    default-domain: com.application.name
    unique-names: true

这篇关于javax.management.InstanceAlreadyExistsException:com.zaxxer.hikari:name = dataSource,type = HikariDataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:02