title: Spring4 boot unittest @ActiveProfiles causing failed to load applicationContext error
body: <p>I want to provide different database for running unitTest than using default production database. I thought about using profile to solve this issue. 
  This is spring4 boot project, so everything is annotated.
  This is what I am doing:</p>
  
  <p>Under src/main/resources, I put <code>application.properties</code>:</p>
  
  <pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/services
  spring.datasource.username=postgres
  spring.datasource.password=postgres
  spring.datasource.driver-class-name=org.postgresql.Driver
  </code></pre>
  
  <p>Under src/test/resources, I put application-test.properties </p>
  
  <pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/services_test
  spring.datasource.username=postgres
  spring.datasource.password=Hercules1
  spring.datasource.driver-class-name=org.postgresql.Driver
  </code></pre>
  
  <p>Then, I put <code>@ActiveProfiles("test")</code> before test, now when I run the unit test, I immediately meet this error:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: Failed to load ApplicationContext</p>
  </blockquote>
  
  <p>I googled quite a lot and nothing can solve this error.</p>
  
  <p>Can you point out what's wrong with my solution?</p>
  
  <p>Thanks</p>