今天在自己搭建Springboot 框架的时候,在配置 logging.config=classpath:logback.xml 出现找不到这个文件的错误,通过发现是maven的一个写法问题,主要原因是mavne 默认的resource会把src/main/resources中资源文件全部放在claaapath目录下,可是我重新定义Maven的resource目录,只把./properties 文件放入,导致找不到loback.xml文件。

<build>
    <resources>
            <resource>
                <targetPath>${project.build.directory}/classes</targetPath>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                  <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>
</build>

 

正确的写法如下:

<build>
    <resources>
            <resource>
                <targetPath>${project.build.directory}/classes</targetPath>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/logback.xml</include>
                </includes>
            </resource>
        </resources>
</build>

写好以后,记得更新下maven,要不然有时候因为缓存问题,而失效。

相关文章:

  • 2021-09-04
  • 2021-10-20
  • 2021-06-27
  • 2021-10-19
  • 2020-01-07
  • 2021-11-04
  • 2021-10-19
猜你喜欢
  • 2021-07-03
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-11-25
相关资源
相似解决方案