spring - @TestPropertySource not working? -


i trying test spring configuration. here config class

@configuration @propertysource("/etc/my.properties") @componentscan("my.package") public class springconfig {      @bean     ..... } 

and when tried test thru test as

@runwith(springjunit4classrunner.class) @testpropertysource(locations = "classpath:test.properties") @contextconfiguration(classes = {springconfiginttest.class, springconfig.class}) public class springconfiginttest {     ....... } 

i keep getting failure saying /etc/my.properties cannot found. think have overridden test.properties , have been googling around without seeing other people doing differently.

i using spring-context, spring-beans, spring-core 4.2.2, , spring-test 4.2.4. can please give me here? appreciate it

you can set property source not fail if resource not exist:

@propertysource(value = "/etc/my.properties", ignoreresourcenotfound = true) 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -