idea解决maven导入pageHelper插件,启动tomcat报ClassNotFoundException: com.github.pagehelper.PageInterceptor问题

由于要是使用分页功能,git有一款非常好的分页插件pagehelper官网:
https://github.com/pagehelper/
根据文档,maven导入,
5.1.10

com.github.pagehelper pagehelper ${PageHelper.version}

配置拦截器(此例用在spring中的SqlSessionFactoryBean配置,文档有详细的配置信息):

    
        
            
                
                    
                    
                        
                        
                        reasonable=true   
                    
                
            
        
    

问题重点:
配置后pageHelper后 ,测试数据没问题,但是用tomcat启动报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘empController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘empServiceImpl’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘empDao’ defined in file [D:\java\item\oa\target\oa-1.0-SNAPSHOT\WEB-INF\classes\com\de\dao\EmpDao.class]: Cannot resolve reference to bean ‘sqlSessionFactory’ while setting bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [applicationContext.xml]: Cannot create inner bean ‘com.github.pagehelper.PageInterceptor#7cddc3db’ of type [com.github.pagehelper.PageInterceptor] while setting bean property ‘plugins’ with key [0]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.github.pagehelper.PageInterceptor] for bean with name ‘com.github.pagehelper.PageInterceptor#7cddc3db’ defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.github.pagehelper.PageInterceptor

总的来说就是找不到nested exception is java.lang.ClassNotFoundException: com.github.pagehelper.PageInterceptor,解决问题步骤:
一般这种编译测试通过,启动tomcat报错ClassNotFoundException:xxx,
首先看一下tomcat打包的依赖:
idea解决maven导入pageHelper插件,启动tomcat报ClassNotFoundException: com.github.pagehelper.PageInterceptor问题_第1张图片
idea解决maven导入pageHelper插件,启动tomcat报ClassNotFoundException: com.github.pagehelper.PageInterceptor问题_第2张图片
发现并没有打包pagehelper

然后看一下项目结构:
idea解决maven导入pageHelper插件,启动tomcat报ClassNotFoundException: com.github.pagehelper.PageInterceptor问题_第3张图片

idea解决maven导入pageHelper插件,启动tomcat报ClassNotFoundException: com.github.pagehelper.PageInterceptor问题_第4张图片
发现war_exploded并没有将pageHelper打包,
发现问题那就简单了,把pagehelper放到lib就行,
idea解决maven导入pageHelper插件,启动tomcat报ClassNotFoundException: com.github.pagehelper.PageInterceptor问题_第5张图片
重启tomcat 成功运行!

你可能感兴趣的:(idea解决maven导入pageHelper插件,启动tomcat报ClassNotFoundException: com.github.pagehelper.PageInterceptor问题)