IDEA maven resource file packaging considerations

background

When I recently used IDEA to package a maven project, I encountered a customer report that the log level was debug, which caused the disk to be full. I have not paid attention to it. Today I specifically looked at the configuration under the class path in the war package. Configuration file.

This is very strange, every time you pack, you have to modify the activeByDefault in pom.xml as the target profile? After repeated testing a few times, I found that the source of the problem is that there are several default configuration files in the resource directory. When packaging, these configuration files are finally in the target war package.

Resource packaging process under resource

### resource default configuration is
After repeated testing a few times, we found that the packaging rules are as follows: 有默认配置文件时 Even if the serial number 3 is configured with true, but the serial number 4 does not check the profile corresponding to pom.xml, the default configuration file will be packaged directly under the class path.

删掉默认配置文件Even if the serial number 3 is configured with true, but the serial number 4 不勾选pom.xml corresponding profile, no configuration file will be packaged under the class path.

删掉默认配置文件Even if the serial number 3 is set to true, but the serial number 4 is 勾选a profile other than 3, the configuration file under the checked profile will be packaged into the class path.

Programming Apocalypse

The conclusion is that the configuration file is dominated by the checked profile when packaging. If not checked, there is no:

  1. Don't put the default configuration file in the resource directory
  2. When packaging, be sure to check the corresponding configuration file directory on the right

Guess you like

Origin juejin.im/post/5e9a346a6fb9a03c74138319