tomcat报错Error during artifact deployment. See server log for details
org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath:spring/applicationContext-*.xml]; nested exception is java.io.FileNotFound
文章目录
日志报错:
org.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 exist
前面是分析问题的原因,想直接看解决办法,跳转到 目录“解决办法” 即可
war和war exploded区别
:
war模式:将WEB工程以包的形式上传到服务器 ;
war exploded模式:将WEB工程以当前文件夹的位置关系上传到服务器;
选择的方式不同,会影响 tomcat catalina.base
这里默认选择的是war exploded,已经选了war模式的话可以在配置里面再修改:
出现标题所示bug的话可以先参考一下这篇博文:
Error during artifact deployment. See server log for details.
这里我的解决方法是根据日志文件的报错信息(报错文件不存在),定位到项目所在的路径
:
一开始以为是上面的路径,然后发现并不是,项目是放在target文件夹下的:
为什么是在target文件夹下呢?看下面的图片
CATALINA_HOME是Tomcat的安装目 录,CATALINA_BASE是Tomcat的工作目录
进入工作目录,然后像我这样一直定位到下图localhost文件夹下的xml文件,会发现它把docBase定位到了target目录
为什么要这样定位到这里呢,因为在下载的tomcat的server.xml里的配置信息是这样的:
解决办法
上面的tomcat路径问题大概算是解决了吧,然后现在来解决实际问题:
进入target目录:
发现之前项目开发时写的一些xml文件并没有在里面反映出来,所以导致tomcat报错找不到***.xml文件,我的解决办法是在pom.xml文件里加入以下配置,把xml文件加载进target(最粗暴的方式是直接把xml文件复制粘贴进target的相应位置)
<build>
<finalName>写自己的项目名字,比如HelloWorld</finalName>
<!--在IDEA中maven 默认编译的时候 只加载src/main/java里面的java文件到target/classes,其他文件会被忽略-->
<!--这时,比如Mybatis的Mapper.xml文件就不能被加载进去,也就是不能映射成功-->
<!--下面配置能解决这个问题-->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
然后这个时候重新运行项目,发现问题解决了
更多推荐
所有评论(0)