spring 整合mybatis 出错,求解决

2017-09-24 21:59:58 [DEBUG] - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2017-09-24 21:59:58 [DEBUG] - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'
2017-09-24 21:59:58 [DEBUG] - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.
2017-09-24 21:59:58 [DEBUG] - Eagerly caching bean 'sqlSessionFactory' to allow for resolving potential circular references
2017-09-24 21:59:58 [DEBUG] - Returning cached instance of singleton bean 'dataSource'
2017-09-24 21:59:58 [DEBUG] - Resolved classpath location [mapper/] to resources [URL [file:/H:/Project/apache-tomcat-8.0.32-windows-x64/apache-tomcat-8.0.32/webapps/wisdomrest/WEB-INF/classes/mapper/]]
2017-09-24 21:59:58 [DEBUG] - Looking for matching resources in directory tree [H:\Project\apache-tomcat-8.0.32-windows-x64\apache-tomcat-8.0.32\webapps\wisdomrest\WEB-INF\classes\mapper]
2017-09-24 21:59:58 [DEBUG] - Searching directory [H:\Project\apache-tomcat-8.0.32-windows-x64\apache-tomcat-8.0.32\webapps\wisdomrest\WEB-INF\classes\mapper] for files matching pattern [H:/Project/apache-tomcat-8.0.32-windows-x64/apache-tomcat-8.0.32/webapps/wisdomrest/WEB-INF/classes/mapper/**/*Mapper.xml]
2017-09-24 21:59:58 [DEBUG] - Searching directory [H:\Project\apache-tomcat-8.0.32-windows-x64\apache-tomcat-8.0.32\webapps\wisdomrest\WEB-INF\classes\mapper\menu] for files matching pattern [H:/Project/apache-tomcat-8.0.32-windows-x64/apache-tomcat-8.0.32/webapps/wisdomrest/WEB-INF/classes/mapper/**/*Mapper.xml]
2017-09-24 21:59:58 [DEBUG] - Resolved location pattern [classpath*:mapper/**/*Mapper.xml] to resources [file [H:\Project\apache-tomcat-8.0.32-windows-x64\apache-tomcat-8.0.32\webapps\wisdomrest\WEB-INF\classes\mapper\menu\menuMapper.xml]]
2017-09-24 21:59:58 [DEBUG] - Invoking afterPropertiesSet() on bean with name 'sqlSessionFactory'
2017-09-24 21:59:58 [DEBUG] - Parsed configuration file: 'class path resource [config/mybatis-config.xml]'
2017-09-24 21:59:58 [WARN] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/applicationContext-db.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [H:\Project\apache-tomcat-8.0.32-windows-x64\apache-tomcat-8.0.32\webapps\wisdomrest\WEB-INF\classes\mapper\menu\menuMapper.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.wisdom.menu.model.Menu'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.wisdom.menu.model.Menu
2017-09-24 21:59:58 [DEBUG] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4719ac62: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,propertiesConfiguration,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,sqlSessionTemplate,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.config.internalTransactionalEventListenerFactory,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,txAdvice,serviceMethods,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor]; root of factory hierarchy
2017-09-24 21:59:58 [DEBUG] - Invoking destroy method 'close' on bean with name 'dataSource'
2017-09-24 21:59:58 [DEBUG] - MBean: com.mchange.v2.c3p0:type=PooledDataSource,identityToken=1b617js9q1dzucff1r9hwem|5af7da9,name=1b617js9q1dzucff1r9hwem|5af7da9 unregistered.
2017-09-24 21:59:58 [DEBUG] - C3P0Registry mbean unregistered.
2017-09-24 21:59:58 [ERROR] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/applicationContext-db.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [H:\Project\apache-tomcat-8.0.32-windows-x64\apache-tomcat-8.0.32\webapps\wisdomrest\WEB-INF\classes\mapper\menu\menuMapper.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.wisdom.menu.model.Menu'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.wisdom.menu.model.Menu
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [catalina.jar:8.0.32]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [catalina.jar:8.0.32]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:8.0.32]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [catalina.jar:8.0.32]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [catalina.jar:8.0.32]
at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_74]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_74]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_74]

3个回答

无法找到你的menu类,在你的menuMapper.xml里。检查一下你的menuMapper是不是有什么地方写的不对。(报错信息: Could not resolve type alias 'com.wisdom.menu.model.Menu'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.wisdom.menu.model.Menu)

也有可能是Mybatis全局配置文件出错,再不是就是你的SQLSessionFactory没配好

可能是数据源配置有问题。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐