?
举例:项目读取pom文件路径的方法:
? ? pom文件内:<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>
?
?
?
?
applicationContext.xml 文件中读取指定地址方法:
? ?<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>
?
?
(文件目录自定义)
以上,applicationContext.xml 就能读取pom里边的值了
?
?
?
?
?
?
?
?
?
?
?
?