Spring Boot 1.4 @DataJpaTest - Error creating bean with name 'dataSource'

后端 未结 1 694
野的像风
野的像风 2021-02-01 05:04

I\'ve created a new spring boot 1.4 application, want to try some testing using @DataJpaTest but keep getting the following error message

Caused by: org.springframew

相关标签:
1条回答
  • 2021-02-01 05:58

    We don't provide an embedded database by default. By default DataJpaTest replaces your DataSource with an embedded database but you don't have one.

    So, if you want to test with MySQL, replace your test as follows:

    @RunWith(SpringRunner.class)
    @DataJpaTest
    @AutoConfigureTestDatabase(replace = NONE)
    final public class MyRepositoryTest {
    }
    

    If you want to use an in-memory database for those tests, you need to add one to the test classpath. Add this to your gradle file

    testCompile('com.h2database:h2')
    
    0 讨论(0)
提交回复
热议问题