最近自己写了个小项目(丛林商城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. Keystone Federation Identity

    转自 http://wsfdl.com/openstack/2016/01/14/Keystone-Federation-Identity.html Keystone federation ident ...

  2. js+css实现简单下拉菜单

    <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312&qu ...

  3. Codeforces 893E Counting Arrays:dp + 线性筛 + 分解质因数 + 组合数结论

    题目链接:http://codeforces.com/problemset/problem/893/E 题意: 共q组数据(q <= 10^5),每组数据给定x,y(x,y <= 10^6 ...

  4. jsp: jstl标签库 uri标签

    与 URL 相关的标签主要是用来将其他文件包含进来,或者提供页面之间的重定位以及 URL 地址的生成.参数的输出等等.一般包括如下几个标签<c:import>标签:与传统 JSP 页面中的 ...

  5. 触摸控(触摸与移动 Touch & Mobility)的官方教程

    http://blogs.msdn.com/b/linanw/archive/2010/05/02/windows-1-wpf-4.aspx

  6. 配置SSH密码登录

    在客户端生成公钥: ssh-keygen –t rsa 生成的公钥默认位置在~/.ssh/目录 把公钥上传到服务器端: scp id_rsa.pub root@ip地址:文件保存路径 cat id_r ...

  7. JVM 知识点总览 - 高级 Java 工程师面试必备

    在江湖中要练就绝世武功必须内外兼备,精妙的招式和深厚的内功,武功的基础是内功.对于武功低(就像江南七怪)的人,招式更重要,因为他们不能靠内功直接去伤人,只能靠招式,利刃上优势来取胜了,但是练到高手之后 ...

  8. svg札记

    1.人老了,有些事情太容易忘记了,这里做下笔记,供参考,for self for you. 2.源于地图监控,建筑级别各大地图商的api(高德.百度.腾讯等)已经足够使用,唯独室内图这块还差点. 3. ...

  9. 01-THREE.JS 第一个场景

    THREE.JS第一个场景 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  10. 【暂时解决】win10下安装VS2017 15.3版本 提示 未能安装包“Microsoft.NET.4.6.FullRedist.NonThreshold.Resources,version=4.6.81.9,language=zh-CN”。

    win10下安装VS2017 15.3版本的时候,出现以上错误日志提示,请问如何解决的哇? 这个问题,开始我以为是我的安装包所在的路径问题引起的,但是我将安装包移动到了磁盘根目录进行安装,依然出现这个 ...