一. java.lang.ClassNotFoundException: org.springframework.web.filter.CharacterEncodingFilter
解决方案:
1.看WEB-INF下面有没有lib,没有就自己创建一个
2.右键改工程,选择properties
3.再选择Deployment Assembly
4.点击add
5.选择Java Build Path Entries后点击next
6.选择Maven Dependencies后点击finish
7.点击Apply后点击OK
重启tomcat就可以了
二. Caused by: java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]
原因: Libraires 里没有相关mysql-connector-java的jar包
扫描二维码关注公众号,回复:
5992179 查看本文章
![](/qrcode.jpg)
解决方法: 在pom.xml 加入以下依赖项即可
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.15</version> </dependency>
三. java.lang.ClassNotFoundException: org.mybatis.spring.SqlSessionFactoryBean
原因: Libraires 里没有org.mybatis的jar包
解决方法: 在pom.xml 加入以下依赖项即可
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.3.2</version> </dependency>
四.mybatis报错:The alias 'xxx' is already mapped to the value 'com.demo.xxx'
经过分析,原来是因为配置文件中,mybatis指定别名时,指定的是一个包路径,而不是一个具体的类。恰巧该项目依赖的jar包中,有2个不同jar包,存在同名类,并且所在包路径的顶层是相同的,故而出现此错误。
修改方法很简单,可以修改配置文件中的包路径,或者修改其中一个类名。