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, 不然將沒法進行轉換java