Spring-Mybatis 异常记录(1)
Spring applicationconfig.xml如下
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:context="http://www.springframework.org/schema/context"xmlns:jee="http://www.springframework.org/schema/jee"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"><!-- 配置数据源 ,连接池用的阿里druid--><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="driverClassName" value="com.mysql.jdbc.Driver"/><!--<property name="url" value="jdbc:mysql://IP+数据库"/><property name="username" value="用户名"/><property name="password" value="密码"/>--><property name="url" value="jdbc:mysql://127.0.0.1:3306/test"/><property name="username" value="root"/><property name="password" value="root"/></bean><!-- 配置mybatis的sqlSessionFactory --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource" /><!-- 自动扫描mappers.xml文件 --><property name="mapperLocations" value="classpath:mapper/*.xml"></property><!-- mybatis配置文件 --><property name="configLocation" value="classpath:mybatis-config.xml"></property></bean><!-- DAO --><bean id="infoDao" class="org.mybatis.spring.mapper.MapperFactoryBean"><property name="mapperInterface" value="net.xjdsz.dao.InfoDao" /><property name="sqlSessionFactory" value="sqlSessionFactory"></property></bean></beans>
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" ><mapper namespace="net.xjdsz.dao.InfoDao"><!-- 查询条件:账号密码用户类型. 0第一个参数,1第二个参数,对应dao接口参数 --><select id="FindAllInfos" resultType="net.xjdsz.model.Info">SELECT * FROM info limit 1</select><!--<select id="getAllUsers" resultMap="userResult">SELECT USER_CODE,USER_NAME,USER_PWD,CREATE_DATEFROM BLOG_USER</select>--></mapper>
<?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"><configuration><mappers><mapper resource="mapper/info.xml"/></mappers></configuration>

package net.xjdsz.service.impl;import net.xjdsz.dao.InfoDao;import net.xjdsz.model.Info;import net.xjdsz.service.InfoService;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;/*** Created by dingshuo on 2017/1/3.*/public class InfoServiceImpl implements InfoService {private InfoDao infoDao;@Overridepublic Info DoWork() {Info info=infoDao.FindAllInfos();return info;}public static void main(String[] args){ApplicationContext ctx = null;ctx = new ClassPathXmlApplicationContext("spring-config/ApplicationContext.xml");InfoDao infoDao=(InfoDao)ctx.getBean("infoDao");Info aaa=infoDao.FindAllInfos();System.out.println(aaa.toString());}}
Connected to the target VM, address: '127.0.0.1:58958', transport: 'socket'一月 03, 2017 5:31:51 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@7a0ac6e3: startup date [Tue Jan 03 17:31:51 CST 2017]; root of context hierarchy一月 03, 2017 5:31:51 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions信息: Loading XML bean definitions from class path resource [spring-config/ApplicationContext.xml]一月 03, 2017 5:31:52 下午 com.alibaba.druid.pool.DruidDataSource info信息: {dataSource-1} initedDisconnected from the target VM, address: '127.0.0.1:58958', transport: 'socket'ID:1,TM:Thu Nov 10 00:00:00 CST 2016,DESC:nihao ,FLAG:0Process finished with exit code 0
Spring-Mybatis 异常记录(1)的更多相关文章
- Maven 搭建SpringMvc+Spring+Mybatis详细记录
总觉得,看比人写的总是那么好,每次搭建框架时都会找博客,找教程来跟着一步一步走,虽然很快搭建成功了,但是经常情况是我并不知道我干了什么,也不记得具体步骤,到底为什么要这么做,今天我详细记录了一下自己搭 ...
- Mybatis 异常记录(1): Invalid bound statement (not found)
错误信息: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pingan.cr ...
- spring奇怪异常记录(会逐渐记录)
1 严重: Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error cr ...
- Spring + MyBatis 框架下处理数据库异常
一.概述 使用JDBC API时,很多操作都要声明抛出java.sql.SQLException异常,通常情况下是要制定异常处理策略.而Spring的JDBC模块为我们提供了一套异常处理机制,这套异常 ...
- Spring+MyBatis时Access denied for user '高欢欢'@'localhost' (using password: YES)的异常解决方案
今天在做spring+mybatis整合的时候系统只要一运行就会报下面的错误,搞了几个小时硬是没有找的原因 警告: com.mchange.v2.resourcepool.BasicResourceP ...
- spring,mybatis事务管理配置与@Transactional注解使用[转]
spring,mybatis事务管理配置与@Transactional注解使用[转] spring,mybatis事务管理配置与@Transactional注解使用 概述事务管理对于企业应用来说是至关 ...
- spring+mybatis+mina+logback框架搭建
第一次接触spring,之前从来没有学过spring,所以算是赶鸭子上架,花了差不多一个星期来搭建,中间遇到各种各样的问题,一度觉得这个框架搭建非常麻烦,没有一点技术含量,纯粹就是配置,很低级!但随着 ...
- SpringMVC+Spring+mybatis项目从零开始--Spring mybatis mysql配置实现
上一章我们把SSM项目结构已搭建(SSM框架web项目从零开始--分布式项目结构搭建)完毕,本章将实现Spring,mybatis,mysql等相关配置. 1. 外部架包依赖引入 外部依赖包引入 ...
- spring,mybatis事务管理配置与@Transactional注解使用
spring,mybatis事务管理配置与@Transactional注解使用[转] spring,mybatis事务管理配置与@Transactional注解使用 概述事务管理对于企业应用来说是 ...
- Spring+MyBatis双数据库配置
Spring+MyBatis双数据库配置 近期项目中遇到要调用其它数据库的情况.本来仅仅使用一个MySQL数据库.但随着项目内容越来越多,逻辑越来越复杂. 原来一个数据库已经不够用了,须要分库分表.所 ...
随机推荐
- Python Counter() 的实现
Table of Contents 1. collections.Counter 源码实现 1.1. __init__ 1.2. update 1.3. most_common 1.3.1. item ...
- AngularJS特性
如果你不熟悉什么是Angular.js的话,小编我强烈推荐你阅读 Javascript教程:AngularJS的五个超酷特性.简单来说Angular.js是google开发者设计和开发的一套前端开发框 ...
- [Java] webservice soap,wsdl 例子
java 调用webservice的各种方法总结 现在webservice加xml技术已经逐渐成熟,但要真正要用起来还需时日!! 由于毕业设计缘故,我看了很多关于webservice方面的知识,今天和 ...
- Java基础知识强化之IO流笔记75:NIO之 Scatter / Gather
1. Java NIO开始支持scatter/gather,scatter/gather用于描述从Channel(译者注:Channel在中文经常翻译为通道)中读取或者写入到Channel的操作. 分 ...
- ionic 中使用ion-slide-box
ion-slide-box 用法: <ion-slide-box class="slide" auto-play="true" does-continue ...
- 【java.math.BigInteger】常用函数
1. /* 返回此BigInteger的函数正负号. 此方法返回-1,0或1作为此BigInteger的值对应是负,零或正数. */ java.math.BigInteger.signum(BigIn ...
- poj 3034 动态规划
思路:这是一道坑爹的动态规划,思路很容易想到,就是细节. 用dp[t][i][j],表示在第t时间,锤子停在(i,j)位置能获得的最大数量.那么只要找到一个点转移到(i,j)收益最大即可. #incl ...
- Atom 下载、安装
Atom工具的使用 由github发布的前端开发工具 非常强大的开发工具 官网下载地址:https://atom.io Atom的插件和主题安装和配置
- Table of Contents - Quartz Scheduler
Getting Started Hello World Integration with Spring Quartz Scheduler Developer Guide Usage of JobDat ...
- Python(2.7.6) 标准日志模块的简单示例
Python 标准库中的 logging 模块提供了一套标准的 API 来处理日志信息的打印. import logging logging.basicConfig( level = logging. ...