SpringBoot 项目 application.properties 无法打包进 target 目录,是什么原因导致的?

springboot项目application.properties 无法打包进 target 目录

原因可能是:

1. application.properties 文件未放置在正确位置

  • 确保文件位于 src/main/resources 目录下。

2. application.properties 文件格式不正确

  • 如果使用 yaml 格式,应命名为 application.yml;如果使用 properties 格式,应命名为 application.properties。

3. maven 配置不当

  • 检查 pom.xml 文件中是否正确配置了资源过滤,如下所示:

    
        
            src/main/resources
            true
        
    

结论:

检查文件位置、格式和 maven 配置,确保 application.properties 文件正确配置,以便在打包时将

其包含在 target 目录中。