接上一篇,导入项目后遇到的问题,

问题一:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [ApplicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [ApplicationContext.xml] cannot be opened because it does not exist

提示找不到ApplicationContext.xml文件,网上找到答案:

使用maven创建web工程,将Spring配置文件applicationContext.xml放在src/resource下,用eclipse编译时提示class path resource [applicationContext.xml] cannot be opened because it does not exist错误。但是用mvn clean package命令编译时成功的。web.xml配置的如下

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

用google搜索一下(之前google用不了,用百度搜到蛋疼),发现是由于classpath不是指向resource路径,导致一直找不到文件。需要在classpath后面加个*,这样就解决问题了。

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>

备注:需要改完所有的存在classpath的地方。

答案地址:https://blog.csdn.net/Mr_Pang/article/details/50854918

 

问题二:

org.apache.jasper.JasperException: Unable to compile class for JSP

应该是因为JDK与Tomcat版本问题所致,

运行环境的JDK为1.8,而启动时使用tomcat:run好像用的是6,

在pom.xml文件中添加依赖:

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>

 之后成功启动项目

posted @ 2020-02-08 13:30  hbx00603006  阅读(137)  评论(0)    收藏  举报