class path resource [logback.xml] cannot be resolved to URL because it does not exist 问题解决

今天在自己搭建Springboot 框架的时候,在配置 logging.config=classpath:logback.xml 出现找不到这个文件的错误

经发现是maven的一个写法问题,本来我是打算打算替换 .properties文件中的内容,后面启动的时候报错,发现主要原因是

mavne 默认的resource会把src/main/resources中资源文件全部放在claaapath目录下,可是我自己重新定义已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,要不然有时候因为缓存问题,而失效

posted @ 2018-10-18 19:12 u清 阅读(...) 评论(...) 编辑 收藏