My Spring Boot project structure is the following:
I have my tests code in the Main class under src/test
, and a test-dedicated properties file under scr/test/resources
I would like to load that file so that i can read its properties from my Main (test) java class, so i do (in the Main class):
But the file is not loaded, at least i assume so, because when i try to read a property in this way:
@Value("${some.property.present.in.that.file}")
private String prop;
then prop
is always null.
I dont understand why this mechanism works in my src/main/java
code but not under test, the ApplicationContext should be there, the Main test class is annotated with @SpringBootTest
which as you can see targets to itself, and the official documentation says:
Any advice about this?