maven hits the jar package, the configuration file is not entered

In the process of packaging the common project today, it was found that the package (jar file) that was typed did not contain the .properties file. When our project read some configurations, the information was written in the weifutong.properties file, and the address is: XXX_common/ src/main/java/com/jf/app/pay/wift/resources/weifutong.properties

Reason: maven only compiles and packages java files by default when packaging (jar)

Workaround: Add the following code in the middle of the pom in the XXX_common project:

  1. <build>  
  2.         <!--Do not filter non-java files when configuring packaging to start -->  
  3.         <!--Indicates that maven will filter out non-java files during modular development and jar package.  
  4.         xml, properties configuration files, etc., but these files are required,  
  5.         Use this configuration to package without filtering these required configuration files.  
  6.         -->  
  7.         <resources>  
  8.             <resource> 
    1.     <!--path -->  
  9.                 <directory>src/main/java</directory>  
  10.                 <includes>  
  11.                     <include>**/*.properties</include> 
  12.                     <include>**/*.xml</include>  
  13.                 </includes>  
  14.                 <filtering>false</filtering>  
  15.             </resource>  
  16.             <resource>  
    1.         <!--Path (if only the above problem is solved, the configuration is not required here) -->  
  17.                 <directory>src/main/resources</directory>  
  18.                 <includes>  
  19.                     <include>**/*.properties</include> 
  20.                     <include>**/*.xml</include>  
  21.                 </includes>  
  22.                 <filtering>false</filtering>  
  23.             </resource>  
  24.         </resources>  
  25.         <!--Do not filter non-java files end when configuring packaging -->  
  26.     </build> 

 

Guess you like

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