记录自己在Demo项目中遇到的异常
一、使用idea中创建maven项目,Maven插件内看不到没有显示mybatis-generator
代码图1
代码
代码图2:Maven插件窗口
解决方法:使用mybatis-generator插件,配置文件内容时需要放在和pluginManagement同级别,修改配置如图:
代码图3
然后刷新maven插件窗口,会显示如下
Jquery异常
jquery-1.11.0.min.js:4 Uncaught TypeError: Illegal invocation
at e (jquery-1.11.0.min.js:4)
at Wc (jquery-1.11.0.min.js:4)
at Wc (jquery-1.11.0.min.js:4)
at Wc (jquery-1.11.0.min.js:4)
at Function.n.param (jquery-1.11.0.min.js:4)
at Function.ajax (jquery-1.11.0.min.js:4)
at HTMLButtonElement.<anonymous> (register.html:94)
at HTMLButtonElement.dispatch (jquery-1.11.0.min.js:3)
at HTMLButtonElement.r.handle (jquery-1.11.0.min.js:3)
排查方法:1、检查前后台请求类型是否一致
2、参数有误,检查参数名称,或是参数对应后台
原因:参数变量名写错
SQL异常
### Error updating database. Cause: java.sql.SQLException: Field 'user_id' doesn't have a default value
###The error may involve com.miaosha.dao.UserPassWordDaoMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: insert into user_password ( encrpt_password ) values ( ? )
### Cause: java.sql.SQLException: Field 'user_id' doesn't have a default value
; ]; Field 'user_id' doesn't have a default value; nested exception is java.sql.SQLException: Field 'user_id' doesn't have a default value]
在排除了数据库的原因,还是会报错,随后检查DaoMapper.xml文件,发现mybatis的自动生成插件没有生成insert语句的id自增属性
如:
<insert id="insertSelective" parameterType="com.miaosha.dataobject.UserDao">
修改后:
<insert id="insertSelective" parameterType="com.miaosha.dataobject.UserDao" useGeneratedKeys="true" keyProperty="id">