最近自己写了个小项目(丛林商城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. Codeforces Round #371 (Div. 2) A ,B , C 水,水,trie树

    A. Meeting of Old Friends time limit per test 1 second memory limit per test 256 megabytes input sta ...

  2. tyvj 1884 [NOIP2000T4]方格取数 || codevs 1043 dp

    P1884 [NOIP2000T4]方格取数 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 [noip2000T4]方格取数 描述 设有N*N的方格图(N& ...

  3. 【转】java中静态方法和非静态方法的存储

    将某 class 产生出一个 instance 之后,此 class 所有的 instance field 都会新增一份,那么所有的 instance method 是否也会新增一份?答案是不会,我们 ...

  4. pandas通过字典生成dataframe

    1.将一个字典输入: 该字典必须满足:value是一个list类型的元素,且每一个key对应的value长度都相同: (以该字典的key为columns) >>> import pa ...

  5. mysql数据简单去重

    我有一个 foo 表,定义了如下几个字段:id / a / b,其中 id 是主键,a,b 原本应该具有唯一性, 但因为程序 bug 导致 a,b 内容有重复,现在我要在 a,b 上加唯一索引,请问如 ...

  6. Oracle Index Clustering Factor(集群因子)

    一.本文说明: 今天在做测试的时候发现字段上有索引,但是执行计划就是不走索引,经过在网上查找才发现原来是索引的集群因子过高导致的.本文属于转载 二.官网说明 The index clustering ...

  7. Python - Package os

    for (path,dirs,files) in os.walk(path): for filename in files: #do something here os. walk(top, topd ...

  8. linux 下sed命令

    sed命令是一个面向字符流的非交互式编辑器,也就是说sed不允许用户与它进行交互操作.sed是按行来处理文本内容的.在shell中,使用sed来批量修改文本内容是非常方便的. sed [选项] [动作 ...

  9. GEF入门实例_总结_05_显示一个空白编辑器

    一.前言 本文承接上一节:GEF入门实例_总结_04_Eclipse插件启动流程分析 在第三节( GEF入门实例_总结_03_显示菜单和工具栏  ),我们创建了菜单和工具栏. 这一节,我们来实现:点击 ...

  10. Java 面向对象编程 tricks

    方法中描述了参数: 1. 构造器重载 重载构造器时,使用描述了参数的静态工厂方法名,这样做的意义何在呢?就在于为动作赋予意义,提升代码的可解释性: 传统的实例化方式: Complex fulcrumP ...