Example: The method for the project to read the path of the pom file:
Inside the pom file: < profiles >
<profile> <id>development</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <web.work.model>normal</web.work.model> <config.root>D:/javaServer/opt/pay/config/basis/wenjianmulu</config.root><dbtype>oracle</dbtype> </properties> </profile> </profiles>
<build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>
The method of reading the specified address in the applicationContext.xml file:
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="locations"> <list> <value>file:${config.root}/xianyu-config-env.properties</value></list> </property> </bean>
(file directory customization)
Above, applicationContext.xml can read the value in pom