I have a Java Spring project configured using Maven. Since the number of unit tests and their configuration files quickly add up, I try to centralize the test configurations into one properties file (the same one that is used when building the project).
Unit tests are located (relative to the project path, of course) in the tree
src / test / java / com (...)
The resource files for these tests are in
src / test / resources (...)
And finally, the properties file that the resource file should read is in the directory
src / main / filters
Now I have a Junit class, where I specify the location of the configuration file as follows:
@ContextConfiguration(locations = { "classpath:com/initrode/quartz/SyncManagerJobTest-context.xml"})
There is a line in the configuration file SyncManagerJobTest-context.xml
<context:property-placeholder location="/src/main/filters/deploy.local.properties"/>
, . , src/main/filters. ../../ , . classpath: . "file:", , .
, : src/test/resources/ src/main/filters?
: Java , "file:" "classpath:"?