Maven Tests with Spring propertyPlaceHolderConfig
This seemingly innocuous combination cost me almost a full day to debug. The error I was getting was:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'mailSender' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Could not resolve placeholder 'smtp.host'
The configuration file was being found, however the properties were not being loaded into by the propertyPlaceHolder. The solution to this is to use the SystemClassLoader, which is not the default for the surefire plugin you can define it like this:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>true</useSystemClassLoader>
<excludes>
<exclude>
this dummy value is to override surefire’s default
</exclude>
</excludes>
</configuration>
</plugin>