1.Error setting null for parameter #10 with JdbcType OTHER .
mybatis 插入空值時需要指定jdbcType
报错内容:
Cause: org.apache.ibatis.type.TypeException:
Error setting null for parameter #10 with JdbcType OTHER .
Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property.
Cause: java.sql.SQLException: 无效的列类型
2.mybatis异常invalid comparison: java.util.Date and java.lang.String
MyBatis 插入空值时,需要指定JdbcType
mybatis insert空值报空值异常,但是在pl/sql不会提示错误,主要原因是mybatis无法进行转换
refundTime != ‘’ 的表达式,这里就相当于date与string比较,故mybatis报错 invalid comparison: java.util.Date and java.lang.String;
2.1 date类型
<if test="createTime != null">
date(create_time) = date(#{createTime,jdbcType=TIMESTAMP})
</if>
2.2 String类型
<if test="createTime != null and createTime != '' " >
date(create_time) = date(#{createTime,jdbcType=TIMESTAMP})
</if>
3.Unparseable date: “xxxxxx”
今天在做保存的时候出现这个bug:Unparseable date: “2019-03-06”,经过查看发现数据库存储这个字段的类型是datatime,所以保存的时候报错,把日期改为2019-03-06 12:35:20 问题解决;这是因为不同的类型支持不同的日期格式。
mysql中常用的日期类型有date,datetime,Timestamp;这三种格式是不一样的。
1.date类型 :Mysql获取和显示这个类型的格式为“YYYY-MM-DD”,支持的时间范围为“1000-00-00”到“9999-12-31”。
2.Datetime类型:存储既有日期又有时间的数据。存储和显示的格式为 “YYYY-MM-DD HH:MM:SS”。支持的时间范围是“1000-00-00 00:00:00”到“9999-12-31 23:59:59”。
3.Timestamp类型:也是存储既有日期又有时间的数据。存储和显示的格式跟Datetime一样。支持的时间范围是“1970-01-01 00:00:01”到“2038-01-19 03:14:07”。
所有不符合上面所述格式的数据都会被转换为相应类型的0值。(0000-00-00或者0000-00-00 00:00:00)
4. InstanceNotFoundException: org.springframework.boot:type=Admin,name=SpringApplication
解决办法:
applicatio.properties配置文件中的logging.level.root的值由debug改为info。希望对大家有帮助
文件级别
Spring支持的所有日志系统都可以在Spring的Environment中设置日志级别(例如在application.properties设置),使用logging.level.=进行设置,LEVEL是TRACE,DEBUG,INFO,WARN,ERROR,FATAL,OFF中的1个。root日志器可以用logging.level.root来配置。例如在application.properties中:
logging.level.root=WARN
logging.level.org.springframework.web=DEBUG
logginglevelorghibernate=ERROR
5.Cannot deserialize value of type java.util.Date from String “2020-03-31”
前端的date类型传过来是string类型,所以需要在entity实体类的属性上面加上 @JsonFormat(pattern = "yyyy-MM-dd")
.
6.The syntax of the string representation of a datetime value is incorrect… SQLCODE=-180, SQLSTATE=22007, DRIVER=4.23.42
DB2数据库报错:
数据库的时间是timeStamp格式,插入进来的是UTC格式。
7.NullPointerException报错
debug时发现shippingOutService对象为null:
== 在对象声明时没有 @autowired==
8. Cannot deserialize instance of java.lang.String
out of START_OBJECT token
因为请求体中的 参数 被认为是一个Object对象,不能用String进行解析,于是 List<String>修改成 List<Object>