Disabling JMX in a spring application

匆匆过客 提交于 2019-12-04 10:36:50

问题


I'm trying to disable jmx so that i don't get org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbeanExporter'anymore.

I've found a partial answer saying that I should include this in the application.properties file:

spring.datasource.jmx-enabled=false

So I created the file with that one line. But how do I make sure that Spring acutally reads it? Do I need to edit something in spring.xml? If so, where?


回答1:


Are you using spring boot? If so you just need to place the file in src\main\resources\application.properties by default

You can check sample projects here https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples




回答2:


You need to disable the setting in your application.properties file (it is automatically turned on if not set). Either edit or create this file: src/main/resources/config/application.properties

That is for a maven project, so if not in maven, just put 'resources' at the same level as your java folder.

You will just need this single line in the file (it can be blank otherwise):

spring.jmx.enabled=false

If you want to add other settings, here are all the options: http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html




回答3:


In my case, it was IntelliJ.

IntelliJ have a setting "Enable JMX agent" in the run configuration. This should be unchecked to disable JMX.

If checked, this will override any setting that you make in the application via properties/yml.




回答4:


You could try to disable jmx autoconfiguration:

@EnableAutoConfiguration(exclude={JmxAutoConfiguration.class})


来源:https://stackoverflow.com/questions/28607506/disabling-jmx-in-a-spring-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!