I am trying to test my Spring Configuration. Here is my config class
@Configuration
@PropertySource("/etc/my.properties")
@ComponentScan("my.package")
public class SpringConfig {
@Bean
.....
}
And when I tried to test it thru my test as
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(locations = "classpath:test.properties")
@ContextConfiguration(classes = {SpringConfigIntTest.class, SpringConfig.class})
public class SpringConfigIntTest {
.......
}
I keep getting the failure saying /etc/my.properties cannot be found. But I think I have overridden it with test.properties and I have been googling around without seeing other people doing it differently.
I am using spring-context, spring-beans, spring-core 4.2.2, and spring-test 4.2.4. Can someone please give me some help here? Deeply appreciate it
@ContextConfiguration(classes = {SpringConfigIntTest.class, SpringConfig.class})with @SpringBootTest(classes = SpringConfigIntTest.class). Here is my another answer with examples to a similar question, which will be of some help. stackoverflow.com/questions/39823045/…