最近自己写了个小项目(丛林商城V1.0),一个简单的网上商铺;主界面是商品的展示和登录,面对三种角色的人群:一般客户,VIP客户,管理员,与之对应的三种商品价格,登陆后根据具体角色来显示商品的价格;还有就是客户添加购物车,下订单,购买商品的简单实现;最后就是管理员有进入后台管理的权限,管理员进入后台管理界面可以管理商品的上架下架以及对所有客户的管理。该项目用spring,struts2和mybatis来完成的,前台框架有用到extjs4.0,其他的就是基本的jsp,js,css操作了。

由于该项目使用了mybatis框架,在没网的条件下跑项目会报:nested exception is java.net.UnknownHostException: mybatis.org异常!

查资料发现是由mybatis配置文件头导致的,如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

有三种解决方法:

1,在项目外添加mybatis-3-config.dtd;

2,在项目内添加mybatis-3-config.dtd(推荐使用);

3,修改mybatisjar包。

因为第3种方法相对难一点,笔者现有水平达不到,所有在这里就简单介绍前两种,朋友们有兴趣可以自己尝试着用第3种方法。

解决办法一:

首先下载mybatis-3-config.dtd文件(网上很多),也可以自己解压mybatis-3.2.0.jar(mybatis框架必须使用的jar包),在里边找mybatis-3-config.dtd文件,其路径是jar解压后mybatis-3.2.0\org\apache\ibatis\builder\xml\mybatis-3-config.dtd;

然后将mybatis-3-config.dtd放在本地,在这里我就放在D:mybatis-3-config.dtd,

最后修改mybatis配置文件头

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"D:/mybatis-3-config.dtd">

解决办法二:

同上,首先下载mybatis-3-config.dtd文件(网上很多),也可以自己解压mybatis-3.2.0.jar(mybatis框架必须使用的jar包),在里边找mybatis-3-config.dtd文件,其路径是jar解压后mybatis-3.2.0\org\apache\ibatis\builder\xml\mybatis-3-config.dtd;

然后将mybatis-3-config.dtd放项目src下(自己也可以定路径)

最后修改mybatis配置文件头

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"/mybatis-3-config.dtd">

上述两种方法笔者亲自试过,可以解决问题!如有问题希望大家能提出来,相互学习!

nested exception is java.net.UnknownHostException: mybatis.org异常处理的更多相关文章

  1. MyBatis与Spring MVC结合时,使用DAO注入出现:Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    错误源自使用了这个例子:http://www.yihaomen.com/article/java/336.htm,如果运行时会出现如下错误: Invocation of init method fai ...

  2. spring和mybatis整合报错:org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError

    Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyExceptio ...

  3. nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoSupport': ...

  4. IDEA报错: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"

    运行审核流模块: 在ActivitiServiceApplication模块日志报错: Error starting ApplicationContext. To display the auto-c ...

  5. spring Boot启动报错Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes

    spring boot 启动报错如下 org.springframework.context.ApplicationContextException: Unable to start web serv ...

  6. Could not get JDBC Connection; nested exception is java.sql.SQLException: ${jdbc.driver}

    在一个SSM分布式项目中一个服务报错: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnec ...

  7. Java AOP nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice || Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0' 两个异常解决办法

    贴出applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans ...

  8. Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill

    异常信息如下: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value ...

  9. Spring系列: 使用aop报错:nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$Refle

    写了个最简单的aop例子 配置文件如下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns ...

随机推荐

  1. Python词云的中文问题

    image= Image.open('F:/__identity/course/建模/九寨沟地震/四川地图.jpg') fig = plt.figure(figsize=(20, 16)) graph ...

  2. Windows 10 SDK 10.0.10069 : The installer failed. User cancelled installation. Error code: -2147023294

    注* 请先跳到文章后面的配置“操作系统的区域设置”部分,然后尝试重试安装VS,如果仍然失败,请看下面内容. 安装UAP SDK失败 Visual Studio 2015 RC Community 安装 ...

  3. MySQL 创建千万集数据

    - MySQL测试任务:使用存储过程,往表中插入千万级数据,根据索引优化速度 -- 1.使用索引查询 -- 2.不使用索引查 -- 3.比较两者查询速度的差异 1.创建数据和索引 1.创建索引测试表 ...

  4. LeetCode OJ:Populating Next Right Pointers in Each Node II(指出每一个节点的下一个右侧节点II)

    Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tre ...

  5. python any函数

    pyhton的any() 函数: 判断给定的可迭代参数 iterable : 全部为 False,返回 False; 至少有一个为 True,则返回 True. 元素除了是 0.空.FALSE 外都算 ...

  6. Sortable

    d_(:з」∠)_ import React, {Component} from 'react'; import "./app.css"; import Sortable from ...

  7. CodeForces - 794C:Naming Company(博弈&简单贪心)

    Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little thi ...

  8. 无状态服务 VS 有状态服务

    无状态服务 VS 有状态服务 https://blog.csdn.net/mysee1989/article/details/51381435 对服务器程序来说,究竟是有状态服务,还是无状态服务,其判 ...

  9. SQL夯实基础(二):连接操作中使用on与where筛选的差异

    一.on筛选和where筛选 在连接查询语法中,另人迷惑首当其冲的就要属on筛选和where筛选的区别了,如果在我们编写查询的时候, 筛选条件的放置不管是在on后面还是where后面, 查出来的结果总 ...

  10. vector的简单运用(士兵队列训练问题)

    某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序 ...