Mybatis异常: protocol = http host = null
2017-02-11 20:54
393 查看
问题现象
程序启动,提示applicationContext.xml文件出错,进一步提示某个mapper文件出错
具体异常信息如下:红色字为出错的Mapper文件,高亮为主要关注异常信息;
原因分析
出现该异常的主要原因是mybatis在调用mapper文件的协议头时,获取不到指定连接;
处理步骤
我的协议头是这样的:
<!DOCTYPEmapper PUBLIC "---mybatis.org--DTD Mapper 3.0--EN""http:--mybatis.org/dtd/mybatis-3-mapper.dtd">
更改后的正确协议头:将“--”更改为“//”
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
程序启动,提示applicationContext.xml文件出错,进一步提示某个mapper文件出错
具体异常信息如下:红色字为出错的Mapper文件,高亮为主要关注异常信息;
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in class path resource [applicationContext.xml]: 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]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\JavaWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Smart\WEB-INF\classes\com\huahai\dao\impl\config\ResidentialInfo_Mapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: java.lang.IllegalArgumentException: protocol = http host = null at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:120) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) |
出现该异常的主要原因是mybatis在调用mapper文件的协议头时,获取不到指定连接;
处理步骤
我的协议头是这样的:
<!DOCTYPEmapper PUBLIC "---mybatis.org--DTD Mapper 3.0--EN""http:--mybatis.org/dtd/mybatis-3-mapper.dtd">
更改后的正确协议头:将“--”更改为“//”
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
相关文章推荐
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- Mybatis异常: protocol = http host = null
- java.lang.IllegalArgumentException: hostname can't be null这个异常的解决办法分析
- android异常解决:org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1 refused
- mybatis查询类型为int的字段,返回null的异常
- Android向Http服务器发送Http请求异常-UnknowHostException
- 严重: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"] java.lang.NullPoin