Spring-Boot module based integration testing

前端 未结 2 1499
逝去的感伤
逝去的感伤 2021-01-12 23:17

I have a multi-module Spring-Boot project. I was wondering how I can set up integration testing just to test Spring Data JPA repositories? The following approach fails with

2条回答
  •  礼貌的吻别
    2021-01-12 23:40

    I resolved this by having the following test config class.

    @Configuration
    @EnableAutoConfiguration
    @ComponentScan
    @PropertySource("classpath:core.properties")
    class TestConfiguration {
    }
    

    core.properties is also used by the main application and it contains datasource information. @IntegrationTest annotation can be removed on the test class.

    I also added the following to the module as dependencies:

    testRuntime 'javax.el:javax.el-api:2.2.4'
    testRuntime 'org.glassfish.web:javax.el:2.2.4'
    

提交回复
热议问题