MyBatis整合Spring相关错误
来源:互联网 发布:淘宝直播 宝贝讲解 编辑:程序博客网 时间:2024/06/05 08:24
在配置MyBatis+Spring+Mysql过程中真是出现各种问题,多数由于粗心导致
错误1:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
MySQl服务没有打开
错误2:
Error creating bean with name 'newsDao' defined in file [D:\WebTest\linglee\target\classes\com\linglee\dao\NewsDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': ...
配置文件application.properties中路径mybatis.config-location的值classpath:mybatis-config.xml多加了一个斜杠。
错误3:org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction;
按照网上说的各种调试,依旧行不通,最后多次检查配置文件application.properties,才发现自己把spring.datasource.username写成spring.datasource.user了,无语
错误4:Cannot read SQL script from class path resource [init-schema.sql]
在InitDatabaseTests test测试中有注解@Sql("/init-schema.sql")错误表名因路径问题无法读取该文件,解决该sql文件要放在main中的resource目录下,不是test
错误5:
Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '' for key 'name',关键字name的唯一性没有保持,但是我在插入时统一setName(""),改成setName(string.format("USER%d",i));或者唯一即可
插入成功
- MyBatis整合Spring相关错误
- Spring整合Mybatis错误
- Spring MVC整合Mybatis的相关配置
- 整合 Spring mvc mybatis 的错误
- springMVC+mybatis+spring整合中varchar错误
- spring-struts-mybatis整合错误集锦
- spring整合mybatis时遇到的错误
- Spring +MyBatis 整合访问数据库出现错误
- Mybatis -- Mybatis整合Spring
- 【Mybatis】Mybatis整合spring
- 【Spring+Mybatis】Spring整合Mybatis
- Spring和mybatis整合时报出的错误
- Spring整合MyBatis错误:org.apache.ibatis.binding.BindingException
- mybatis与spring整合之错误定义sqlSessionFactoryBean
- Spring+Mybatis整合时Caused by: java.lang.IllegalArgumentException错误
- spring 整合mybatis配置 MapperScannerConfigurer,无法读配置文件错误
- 搭建Spring+Springmvc+mybatis整合框架的错误日记
- MyBatis-----2、MyBatis整合Spring
- java 9
- java9
- 系统移植:2. u-boot的烧写及使用
- android如何同时控制EditText输入字符个数和禁止特殊字符输入?
- java11
- MyBatis整合Spring相关错误
- 对象与对象引用---2种相似的解释(以java为例)
- 索引高效排序法,10000长度随机数组排序 200毫秒
- tcp/ip 编程之基本概念
- Java中的关键字
- HTML知识续
- window下配置mysql远程访问
- NAT穿透的详细讲解及分析
- Effective Java读书笔记十七(Java Tips.Day.17)