Intellij IDEA Tomcat启动项目报错:java.lang.ClassNotFoundException
1.问题描述:
今天学java-web项目时,遇到了一个奇怪的问题。写DAO时,用到了JdbcTemplate和BeanPropertyRowMapper,相关的jar包都放入了web-WEB-INF-libs下面,而且本地测试DAO时并无报错。但部署到Tomcat上运行,使用DAO接口时却报错了:java.lang.ClassNotFoundException: org.springframework.jdbc.core.RowMapper

2.解决方案:
File->Project Structure->Artifacts->对应的模块->output layout,将jar包导入


再重新启动服务器就不会报错了。
3.自动导入
每次都需要这样导入太过于麻烦,可以通过设置marven import来自动导入。
设置->Build,Execution,Deployment->Build Tools->Maven

确保 ignored 没有本项目的pom

参考:
网友评论