title: Spring Boot MockMvc test giving 404 for actuator endpoint when using the "management.server.port" property instead of the deprecated "management.port"
body: <p>I was earlier using the management.port in the application yaml for the management endpoint port. However, changed it to using as in the below application yaml file. It has been failing my actuator test for the health endpoint. The endpoint works as normal when i run the application.</p>
  <p>application.yaml</p>
  <pre><code>spring:
    profiles.active: development
  
  management:
    endpoints:
      web:
        exposure:
          include: &quot;*&quot;
    server:
      port: 9000
  
  server:
    port: 8000
  ---
  spring:
    profiles: development
  
  logging:
    level:
      root: INFO
      org.springframework.web: INFO
  
  ---
  spring:
    profiles: staging
  
  logging:
    level:
      root: ERROR
      org.springframework.web: ERROR
  </code></pre>
  <p>Integration Test Class</p>
  <pre><code>package com.rps;
  
  import static org.junit.Assert.assertNotNull;
  import static org.junit.Assert.assertThat;
  import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
  import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
  
  import com.rps.infrastructure.repository.PlayersInMemoryRepository;
  import org.hamcrest.Matchers;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.test.context.SpringBootTest;
  import org.springframework.http.MediaType;
  import org.springframework.test.context.ActiveProfiles;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  import org.springframework.test.web.servlet.MockMvc;
  import org.springframework.test.web.servlet.setup.MockMvcBuilders;
  import org.springframework.web.context.WebApplicationContext;
  
  /**
   * Integration testing the actual API Check the guide here: https://spring.io/guides/gs/testing-web/
   */
  @SpringBootTest
  @RunWith(SpringJUnit4ClassRunner.class)
  public class RPSApplicationIT {
  
    @Autowired
    private WebApplicationContext context;
  
    @Autowired
    private PlayersInMemoryRepository playersInMemoryRepository;
  
    private MockMvc mockMvc;
  
    @Before
    public void setupMockMvc() {
      mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
    }
  
    @Test
    public void shouldReturnActuatorHealthResponse() throws Exception {
      this.mockMvc.perform(get(&quot;/actuator/health&quot;))
          .andDo(print())
          .andExpect(status().isOk())
          .andExpect(content().json(&quot;{\&quot;status\&quot;:\&quot;UP\&quot;}&quot;));
    }
  
  }
  
  </code></pre>