class path resource [logback.xml] cannot be resolved to URL because it does not exist 问题解决
今天在自己搭建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,要不然有时候因为缓存问题,而失效。