title: Use embedded database for test in spring boot
body: <p>I have a spring boot application, it has a couple of <code>@Entity</code> classes and <code>@RepositoryRestResource</code> repositort interfaces for them. Now I want to write some tests, where I can check that I can add a new record into my database using those repositories, but I don't want to use my configured MySQL database for it, but instead I want to use some embedded db like H2. At the moment I have an <code>application.properties</code> file, which looks like this:</p>
  
  <pre><code>spring.jpa.hibernate.ddl-auto=create
  spring.datasource.url=jdbc:mysql://localhost:3306/mydb
  spring.datasource.username=root
  spring.datasource.password=qwerty123
  </code></pre>
  
  <p><strong>Question:</strong> How do I configure my app to use other db for tests? I have no xml in my project, everything is based on annotations. I tried to define <code>@Configuration</code> class with  <code>@Bean</code> to create <code>DataSource</code> and then use it with <code>@ContextConfiguration</code> annotation on test class, but it says that it can't load context.</p>