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

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  2. Python去除字符串的空格

    Python能够找出字符串开头和末尾多余的空白. 要确保字符串末尾没有空白,可使用方法rstrip(). 还可以剔除字符串开头的空白,或同时剔除字符串两端的空白. 为此,可分别使用方法lstrip() ...

  3. numpy 往array里添加一个元素

    首先这里p_arr为一个numpy的array,p_为一个元素 p_arr = np.concatenate((p_arr,[p_])) # 先将p_变成list形式进行拼接,注意输入为一个tuple ...

  4. Liberty glance 新功能 healthcheck

    oslo.middleware‘s healthcheck http://specs.openstack.org/openstack/oslo-specs/specs/kilo/oslo-middle ...

  5. 【疯了C#】神奇的换肤(二)

    昨天参照了网上的资料练习了换肤,今天进一步的实现选择换肤 其实很简单,需要实现的功能如下点击combobox中的不同项目然后面板会自动的切换到相应的界面主题. 界面如下: 下述代码参照 “张隽永” 博 ...

  6. sorket is closed

    今早来公司启动项目时,发现在代码正确的情况下报了一个错. 15:19:14.362 [http-9000-2] ERROR com.nari.osp.servicebus.rmi.LongConnec ...

  7. 分享知识-快乐自己:Java中的经典算法之冒泡排序(Bubble Sort)

    原理:比较两个相邻的元素,将值大的元素交换至右端. 思路:依次比较相邻的两个数,将小数放在前面,大数放在后面.即在第一趟:首先比较第1个和第2个数,将小数放前,大数放后.然后比较第2个数和第3个数,将 ...

  8. Eclipse_插件_05_自动下载jar包源码插件

    一.Java Source Attacher 1.下载 官网:http://marketplace.eclipse.org/content/java-source-attacher#.U5RmTePp ...

  9. C# 之二进制序列化

    序列化:又称串行化,是.NET运行时环境用来支持用户定义类型的流化的机制.其目的是以某种存储形成使自定义对象持久化,或者将这种对象从一个地方传输到另一个地方. 一般有三种方式:1.是使用BinaryF ...

  10. 一些神奇的(优化)板子——来自Loi_black的博客

    deque<int>q; void spfa(int s) { ;i<=n;i++) d[i]=1e9; d[s]=; q.push_back(s); used[s]=; while ...