如何在JHIPSTER生成的上下文中更改HikariDataource bean名称?

时间:2018-04-12 06:35:17

标签: java spring spring-boot jhipster

如果我尝试在单个tomcat中部署两个JHIPSTER CONTEXT' S WAR,则抛出一个摘要

那么如何在上下文中更改HIkariCP bean名称。

异常日志:

org.springframework.jmx.export.UnableToRegisterMBeanException:无法使用key' dataSource'注册MBean [HikariDataSource(hikariDataSourceVirtuoSuite)]嵌套异常是javax.management.InstanceAlreadyExistsException:com.zaxxer.hikari:name = dataSource,type = HikariDataSource         在org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:628)         在org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550)         在org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432)         在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:781)         在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)         在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)         at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)         在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)         在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)         在org.springframework.boot.SpringApplication.run(SpringApplication.java:303)         在org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)         在org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)         在org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)         在org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)         在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5622)         在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)         在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1009)         在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:985)         在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)         在org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)         在org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:2020)         at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)         在java.lang.Thread.run(Thread.java:748) 引起: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 com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)         at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)         在org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:195)         在org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:674)         在org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:618)         ...省略了25个常见帧

2018-04-11 20:03:51.194 WARN 10440 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext:在关闭上下文时从LifecycleProcessor抛出的异常

java.lang.IllegalStateException:LifecycleProcessor未初始化 - 调用'刷新'在通过上下文调用生命周期方法之前:org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@f46e3f7:启动日期[Wed Apr 11 20:03:32 IST 2018];上下文层次结构的根         在org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:427)         在org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:999)         在org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)         在org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)         在org.springframework.boot.SpringApplication.run(SpringApplication.java:314)         在org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)         在org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)         在org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)         在org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)         在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5622)         在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)         在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1009)         在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:985)         在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)         在org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)         在org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:2020)         at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)         在java.lang.Thread.run(Thread.java:748)

2018年4月11日下午8:03:51 org.apache.catalina.core.ContainerBase addChildInternal 严重:ContainerBase.addChild:开始: org.apache.catalina.LifecycleException:无法启动组件[StandardEngine [Catalina] .StandardHost [localhost] .StandardContext [/ VirtuoSuite]]         在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)         在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1009)         在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:985)         在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)         在org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)         在org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:2020)         at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)         在java.lang.Thread.run(Thread.java:748) 引起:org.springframework.jmx.export.UnableToRegisterMBeanException:无法使用密钥' dataSource';注册MBean [HikariDataSource(hikariDataSourceVirtuoSuite)]嵌套异常是javax.management.InstanceAlreadyExistsException:com.zaxxer.hikari:name = dataSource,type = HikariDataSource         在org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:628)         在org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550)         在org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432)         在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:781)         在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)         在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)         at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)         在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)         在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)         在org.springframework.boot.SpringApplication.run(SpringApplication.java:303)         在org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)         在org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)         在org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)         在org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)         在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5622)         在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)         ......还有10个 引起: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 com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)         at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)         在org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:195)         在org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:674)         在org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:618)         ......还有25个

2018年4月11日下午8:03:51 org.apache.catalina.startup.HostConfig deployWAR 严重:部署Web应用程序存档时出错:C:\ Program Files \ Apache Software Foundation \ apache-tomcat-7.0.81 \ webapps \ VirtuoSuite.war java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:无法启动组件[StandardEngine [Catalina] .StandardHost [localhost] .StandardContext [/ VirtuoSuite]]         在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1013)         在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:985)         在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)         在org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)         在org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:2020)         at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)         at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)         在java.lang.Thread.run(Thread.java:748)

2018年4月11日下午8:03:51 org.apache.catalina.startup.HostConfig deployWAR

1 个答案:

答案 0 :(得分:1)

Java管理扩展(JMX)管理Bean的创建,因此,如果我们更改jmx默认域名属性值,则每个上下文都有不同的域名。因此,tomcat中没有两个bean具有相同的名称。

application.yml 文件中添加以下属性。

JMX default domain configuration in JHipster context

在这里, 一切:这在tomcat的上下文中不会重复。主要是“应用程序名称”本身。