Cannot integrate JMX with Spring application

后端 未结 2 1776
悲&欢浪女
悲&欢浪女 2021-01-07 04:11

I have got a SPRING application. When I run

mvn jetty:run

everything is ok.

I would like to use JMX

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-07 04:43

    This is happening as the bean is trying to initialize even after its initialized once.

    I was facing the same issue with RabbitMQ configuration in Spring TestNG testcases.

    Use @DirtiesContext as a class level annotation for every testcase class.

    This will create applicationcontext and kill it once the testcase class is run and a new applicationcontext will be created for the next testcase class.

    Example -

    @Test
    @ContextConfiguration(classes = { ApplicationConfig.class })
    @DirtiesContext
    @WebAppConfiguration
    public class ATest extends AbstractTestNGSpringContextTests{
        @BeforeSuite
        public void setup() throws Throwable {
    
        }
        @AfterSuite
        public void teardown() {
    
        }
    }
    

提交回复
热议问题