mybatis在tomcat调试过程中,自动部署后会报错

J2EE 码拜 9年前 (2016-06-04) 1329次浏览
21:32:31.907 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name "sqlSessionFactory" defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: "file [E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\movie\WEB-INF\classes\mybatis\mapping\CountryMapper.xml]"; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias "com.cn.movie.entity.Country".  Cause: java.lang.ClassNotFoundException: Cannot find class: com.cn.movie.entity.Country
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797) [catalina.jar:7.0.37]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291) [catalina.jar:7.0.37]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.37]
	at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3926) [catalina.jar:7.0.37]
	at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426) [catalina.jar:7.0.37]
	at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345) [catalina.jar:7.0.37]
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530) [catalina.jar:7.0.37]
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) [catalina.jar:7.0.37]
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) [catalina.jar:7.0.37]
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519) [catalina.jar:7.0.37]
	at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: "file [E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\movie\WEB-INF\classes\mybatis\mapping\CountryMapper.xml]"; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias "com.cn.movie.entity.Country".  Cause: java.lang.ClassNotFoundException: Cannot find class: com.cn.movie.entity.Country
	at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:484) ~[mybatis-spring-1.2.5.jar:1.2.5]
	at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:355) ~[mybatis-spring-1.2.5.jar:1.2.5]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
	... 23 common frames omitted
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias "com.cn.movie.entity.Country".  Cause: java.lang.ClassNotFoundException: Cannot find class: com.cn.movie.entity.Country
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92) ~[mybatis-3.3.1.jar:3.3.1]
	at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:482) ~[mybatis-spring-1.2.5.jar:1.2.5]
	... 26 common frames omitted
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias "com.cn.movie.entity.Country".  Cause: java.lang.ClassNotFoundException: Cannot find class: com.cn.movie.entity.Country
	at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:118) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:68) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:135) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118) ~[mybatis-3.3.1.jar:3.3.1]
	... 28 common frames omitted
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias "com.cn.movie.entity.Country".  Cause: java.lang.ClassNotFoundException: Cannot find class: com.cn.movie.entity.Country
	at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:120) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:149) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:116) ~[mybatis-3.3.1.jar:3.3.1]
	... 32 common frames omitted
Caused by: java.lang.ClassNotFoundException: Cannot find class: com.cn.movie.entity.Country
	at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:200) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.io.Resources.classForName(Resources.java:261) ~[mybatis-3.3.1.jar:3.3.1]
	at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116) ~[mybatis-3.3.1.jar:3.3.1]
	... 34 common frames omitted

这是错误代码,但是说没有找到类java.lang.ClassNotFoundException: Cannot find class: com.cn.movie.entity.Country,也不是呀。这个类是肯定有的..本人在单元测试时候,这个xml里边的全部方法都可以执行通过的,但是就是在本人不管他调试其他的代码时候,tomcat自动部署了,然后就出现这些问题了..

解决方案

40

是maven项目吧,本人记得本人确实也遇到过相似的问题,用maven的tomcat插件部署出现过这种情况
你自动部署后可以去tomcat的webapps看看,肯定是少文件,所以这里才找不到,估计就没编译这个类~
所以还是手动部署吧,本人当时就这样处理的

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明mybatis在tomcat调试过程中,自动部署后会报错
喜欢 (0)
[1034331897@qq.com]
分享 (0)