Mybatis的拦截器,有时可以使用,有时又莫名其妙不可以使用,时不时就会报找不到拦截器类
来源:4-5 商户模块_Mybatis多对一和一对一及引用静态常量的应用
迷茫_坚定
2017-09-06
Caused by: org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.interceptor.PageInterceptor'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.interceptor.PageInterceptor
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:500)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 49 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.interceptor.PageInterceptor'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.interceptor.PageInterceptor
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:115)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:95)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:494)
... 52 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.interceptor.PageInterceptor'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.interceptor.PageInterceptor
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.pluginElement(XMLConfigBuilder.java:148)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:104)
... 54 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.interceptor.PageInterceptor'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.interceptor.PageInterceptor
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:120)
at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:149)
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:116)
... 56 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: com.interceptor.PageInterceptor
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:200)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89)
at org.apache.ibatis.io.Resources.classForName(Resources.java:261)
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116)
... 58 more
不晓得为什么会报这错误,
1回答
-
源生活
2017-09-07
开发工具每次重新打开确实可能会出现这种情况,需要在Tomcat下重新【Publish】一下工程,如果还是不行,你可以随意修改工程里一个文件,比如加个空格或回车,让Tomcat出现【Republish】的提示,然后【Publish】,一定有效,就是让Tomcat知道工程有变化,需要重新部署,这个时候就好了,可能是开发工具每次重新打开后,Tomcat上次部署的工程会缺class,具体原因不明,可能是eclipse的一个bug。
022017-09-07
IT段子手详解MyBatis遇到Spring 秒学Java SSM开发大众点评
1001 学习 · 485 问题
相似问题