使用Maven 经常会出现一些问题。今天项目出了点 问题,在多次尝试下无果,然后在 Maven 里就 clean 了项目,然后重新编译,这时报错如下。

[CONSOLE] 2017-09-18 09:19:54,764 - org.springframework.web.context.ContextLoader -1 [RMI TCP Connection(2)-127.0.0.1] ERROR org.springframework.web.context.ContextLoader - Context initialization failedorg.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath:spring/applicationContext-*.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/] cannot be resolved to URL because it does not existat org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:229)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:604)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:509)at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)at

主要是这句

Could not resolve bean definition resource pattern [classpath:spring/applicationContext-*.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/] cannot be resolved to URL because it does not exist

很明显是 无法找到 classpath 下的 spring 文件夹。

这个问题和 Maven 无法生成resource下的文件 相同。

先看 项目结构

然后 我们看了一下 Maven 编译生成的文件,md,怎么只有一个log4j的配置文件,我的spring和mybatis 文件夹呢?

我记得在 pom.xml 里已经配置过了让其生成,然后网上查了一些人家的方法,纳尼?怎么这里是 true ?我的是 false 。

<filtering>true</filtering>

最终解决方案如下

在 pom.xml 里添加如下代码

  1. <build>
  2. <finalName>ForestBlog</finalName>
  3. <resources>
  4. <resource>
  5. <directory>src/main/java</directory>
  6. <includes>
  7. <include>**/*.properties</include>
  8. <include>**/*.xml</include>
  9. </includes>
  10. <filtering>true</filtering>
  11. </resource>
  12. </resources>
  13. </build>

我的错误是 第10行 是 false,那为什么之前却有用呢?难不成谁给我改成false了?

然后再次启动 Tomcat,就可以看到Maven在 target 生成了文件

如果还是不行,我还是会遇到添加了上面的代码,但是还是无法生成 mybatis和spring,以及那两个properties文件的情况。不要急,这时候可以试试 clean (删除target),然后在启动 Tomcat。

本文地址:https://liuyanzhao.com/6255.html

class path resource [spring/] cannot be resolved to URL because it does not exist相关推荐

  1. class path resource [spring/] cannot be resolved to URL because it does not exist问题解决(IDEA)

    问题 Caused by: java.io.FileNotFoundException: class path resource [spring/] cannot be resolved to URL ...

  2. class path resource [mapper/] cannot be resolved to URL because it does not exist解决办法

    此错误信息为:无法将类路径资源[mapper/]解析为URL,因为它不存在. 由此可知在我们的applicationContext.xml文件中的mapper路径配置不正确 我是在我的classpat ...

  3. lass path resource [com/spring/] cannot be resolved to URL because it does not

    class path resource [com/spring/] cannot be resolved to URL because it does not 解决办法: 在配置文件中的:

  4. 问题备忘: class path resource [xx] cannot be resolved to absolute file path because it does not reside

    问题描述 测试服务的版本是Spring Cloud Dalston.SR5 在Spring Boot中配置https时,代码如下: @Bean@ConditionalOnExpression(&quo ...

  5. class path resource [log4j.properties] cannot be resolved to URL because it does not exist

    从svn上拉代码,然后在导进eclipse,启动Tomcat,报错 Invalid 'log4jConfigLocation' parameter: class path resource [log4 ...

  6. Error creating bean with name 'dataSource' defined in class path resource [spring/spring-dao.xml]:

    Error creating bean with name 'dataSource' defined in class path resource [spring/spring-dao.xml]: B ...

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

    class path resource [logback.xml] cannot be resolved to URL because it does not exist 问题解决 参考文章: (1) ...

  8. class path resource [logback-spring.xml] cannot be resolved to URL because it does not exist的处理方法

    class path resource [logback-spring.xml] cannot be resolved to URL because it does not exist的处理方法 很多 ...

  9. 关于sping使用springSecurity权限控制:Offending resource: class path resource [spring/spring-security.xml错误整理

    严重:Exception sending context initialized event to listener instance of class org.springframework.web ...

  10. class path resource [a.hbm.xml] cannot be opened because it does not exist

    大家好,我是mythSun. 很高兴能在这里和大家分享,怎么来解决 class path resource [a.hbm.xml] cannot be opened because it does n ...

最新文章

  1. 4种营销场景满足其中一个要不要做小程序?
  2. Win7环境下IPython Notebook的安装
  3. IDEA导入项目笔记二
  4. easyui datagrid加载本地数据和网络数据
  5. JAVA GUI THREAD---***
  6. linux的三大服务器,Linux三大重要事件
  7. RHCE之DHCP配置详解
  8. Visual studio 2013 添加 GitHub
  9. 计算机网络南京邮电大学,南京邮电大学计算机网络.docx
  10. 传智播客java学习内容
  11. [Unity][AssetStore][PacakageManager]2020.1版本后的AssetStore如何下载资源并导入编辑器以及Error refreshing packages解决办法
  12. windows 超简单实现多用户远程桌面,RDP WRAPPER
  13. [Halcon测量] 测量助手详解
  14. 公众号采集文章插件下载-支持各大网站自动采集发布的公众号插件
  15. 请求服务器获取微信openid,Golang通过小程序获取微信openid的方法示例
  16. 谈谈Processing 3D世界 一
  17. 查杀linux服务器木马,定时查杀病毒并隔离
  18. 华为芯片鸿蒙的由来,华为“鸿蒙”真的来了!看完这些商标来历,网友们又激动了...
  19. 【测试】功能测试用例设计方法总结
  20. 如何用齿轮法测定光速

热门文章

  1. text函数--Matplotlib
  2. Java高级程序员面试大纲——备战金三银四跳槽季
  3. 【编译打包】nginx-1.4.7-1.el6.lite.src.rpm
  4. [React-Native]环境配置amp;HelloWorld
  5. 也用 Log4Net 之走进Log4Net (四)
  6. IOS 学习笔记 2015-04-10 OC-常用常量
  7. u盘安装linux6.5教程,u盘安装CentOS6.5
  8. java 序列号 1l_private static final long serialVersionUID=1L 是什么意思
  9. 分组 php库,ThinkPHP分组下自定义标签库实例
  10. pyzabbix 删除触发器_Zabbix实现批量监控端口状态的方法