package com.webapp.hanqi.test; import java.util.Date; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext; import com.webapp.hanqi.dao.AppUserDao;
import com.webapp.hanqi.model.AppUser; class AppWebTest { ClassPathXmlApplicationContext c;
AppUserDao appUserDao; @Test
void test() {
AppUser user = new AppUser();
user.setUname("admin333");
user.setPword("123");
user.setCtime(new Date());
user.setRname("测试用户");
// user.setEmail("25673578@qq.com");
user.setCdkey("abc");
int u = appUserDao.insert(user);
System.out.println(u);
} @BeforeEach
void setUp() throws Exception {
c = new ClassPathXmlApplicationContext("conf/spring-all.xml");
appUserDao = c.getBean(AppUserDao.class);
} @AfterEach
void tearDown() throws Exception {
c.close();
} }
添加一条数据时, email列被报出无效的列类型的异常, 原因是mybatis在插入空值的时候需要指定jdbcType, 否则将无法进行转换