java Maven: How to get the key value of maven's pom.xml in the properties file

 

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

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326116349&siteId=291194637