最近自己写了个小项目(丛林商城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. 总结django知识点

    一.视图函数:     请求对象-----------request:           1.HttpRequest.body:         请求原数据           2.HttpRequ ...

  2. DelphiXE

    1. http://blog.csdn.net/tp26021340/article/details/45953669 2. 3. 4. 5.

  3. js 图片加载失败处理方法

    在项目中不可避免会用到图片,尤其是列表,有时候图片会加载失败:这样就会显示一个很难看的坏图片缩略图:下面介绍两种方法,解决这个问题: 1.如果在你的项目中有引入jQuery插件,你可以使用error( ...

  4. 我总结的call()与apply()方法的区别

    [call()与apply()的区别]在ECMAScript中每一个函数都是function类型(是javascript的基本引用类型)的实例,具有一定的属性和方法.call()和apply()则是这 ...

  5. Spring MVC数据绑定大全 .

    刚开始用spring mvc 做web开发时,经常会不知道如何合适绑定页面数据.用惯struts2的朋友更认为spring mvc 绑定数据不如struts2方便(本人最开始也是这么认为),经过一段时 ...

  6. HANA IMPORT AND EXPORT

    权限管控的过于严格,所以找机会写个导入导出的流程.从测试机传输到生产机 1 选中EXPORT , 导出将要传输的模型 也可以 在QUICK VIEW 里选中导入导出.个人爱好 2 选择传输的两种模式 ...

  7. 20165210 Java第三次实验报告

    20165210 实验二 敏捷开发与XP实践 一.敏捷开发与XP实践-1 实验要求: http://www.cnblogs.com/rocedu/p/4795776.html, Eclipse的内容替 ...

  8. BEC translation exercise 4

    People have long known that nuts are part of a healthy diet.人们早就知道坚果是健康饮食的一部分.People, who you know w ...

  9. Redis 高可用及分片集群,说了你也不懂

    Redis 简介 Memcached: 优点:高性能读写.单一数据类型.支持客户端式分布式集群.一致性hash 多核结构.多线程读写性能高. 缺点:无持久化.节点故障可能出现缓存穿透.分布式需要客户端 ...

  10. CodeForces - 827A:String Reconstruction (基础并查集)

    Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun ...