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}/classestargetPath>
                <directory>src/main/resourcesdirectory>
                <filtering>truefiltering>
                <includes>
                  <include>**/*.propertiesinclude>
                includes>
            resource>
        resources>
build>

 

正确的写法如下:

<build>
    <resources>
            <resource>
                <targetPath>${project.build.directory}/classestargetPath>
                <directory>src/main/resourcesdirectory>
                <filtering>truefiltering>
                <includes>
                    <include>**/*.propertiesinclude>
                    <include>**/logback.xmlinclude>
                includes>
            resource>
        resources>
build>

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

转载于:https://www.cnblogs.com/uqing/p/9812547.html

你可能感兴趣的:(java)