title: Spring Boot integration tests cannot reach application.properties file
body: <p>I have some classes annotated with <code>@RestController</code> that I'm trying to test using the <code>MockMvc</code> class. The end-points respond properly from a web application, but I get the following error when running the tests (from IntelliJ IDEA):</p>
  
  <pre><code>java.lang.IllegalArgumentException: Could not resolve placeholder
  'spring.data.rest.base-path' in string value "${spring.data.rest.base-path}/whatever"
  </code></pre>
  
  <p>This is how the <code>application.properties</code> file looks like:</p>
  
  <pre><code>spring.data.rest.base-path=/api
  spring.profiles.active=dev
  ...
  </code></pre>
  
  <p>I also have a file called <code>application-dev.properties</code> with additional (different) properties.</p>
  
  <p>This is how the test classes are annotated:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(classes = Application.class)
  @WebIntegrationTest // Also tried: @WebAppConfiguration
  @ActiveProfiles("dev")
  // Also tried: @PropertySource("classpath:application.properties")
  // Also tried: @TestPropertySource("classpath:application.properties")
  public class MyRestControllerTest {
      ...
  }
  </code></pre>
  
  <p>On the other hand, this is how the REST controllers are implemented (where the problematic property is being used):</p>
  
  <pre><code>@RestController
  @RequestMapping("${spring.data.rest.base-path}/whatever")
  public class MyRestController {
      ...
  }
  </code></pre>
  
  <p>This is how the application's main class looks like:</p>
  
  <pre><code>@SpringBootApplication(scanBasePackages = {...})
  @EnableJpaRepositories({...})
  @EntityScan({...})
  public class Application {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>And finally, this is (a subset of) the project's structure:</p>
  
  <pre><code>my-project
  |_ src
     |_ java
     |  |_ com.example.x
     |     |_ controller
     |        |_ MyRestController.java
     |
     |_ test
     |  |_ com.example.x
     |     |_ controller
     |        |_ MyRestControllerTest.java
     |
     |_ resources
        |_ application.properties
        |_ application-dev.properties
  </code></pre>
  
  <p>I've found several solutions to the problem throughout the web, but none of them seemed to work for me.</p>