java Maven: 如何在properties文件中获取maven的 pom.xml 的键值

阅读更多

 

举例:项目读取pom文件路径的方法:

    pom文件内:<profiles>

   <profile>
      <id>developmentid>
      <activation>
         <activeByDefault>trueactiveByDefault>
      activation>
      <properties>
         <web.work.model>normalweb.work.model>
         <config.root>D:/javaServer/opt/pay/config/basis/wenjianmuluconfig.root><dbtype>oracledbtype>
      properties>
   profile>

profiles>

 

 

<build>
   <resources>
      <resource>
         <directory>src/main/resourcesdirectory>
         <filtering>truefiltering>
      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.propertiesvalue>list>
   property>
bean>

 

 

(文件目录自定义)

以上,applicationContext.xml 就能读取pom里边的值了

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(java,maven,properties,pom.xml)