@TestPropertySource doesn't work for JUnit test with AnnotationConfigContextLoader in Spring 1.2.6

后端 未结 7 2059
无人及你
无人及你 2020-12-01 10:34

It doesn\'t seem that anything I do in Spring 4.1.17 with Spring Boot 1.2.6.RELEASE works at all. I just want to access the application properties and override them with te

7条回答
  •  猫巷女王i
    2020-12-01 11:08

    I had issue with @TestPropertySource. test.properties not found

    below is the one before fixed

    @RunWith(SpringRunner.class)
    @ContextConfiguration(classes = ExtContext.class)
    @TestPropertySource(locations = "classpath: test.properties")
    

    i removed space between classpath: and test.properties as below

    @RunWith(SpringRunner.class)
    @ContextConfiguration(classes = ExtContext.class)
    @TestPropertySource(locations = "classpath:test.properties")
    

    This worked for me, When test.properties is not found in classpth. misht work for you aswell

提交回复
热议问题