package com.liuhao.test;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.liuhao.entity.User;
import com.liuhao.service.UserService;
public class SpringBatis {
ApplicationContext context = null;
UserService userService = null;
@Before
public void initContext() {
this.context = new ClassPathXmlApplicationContext("applicationContext.xml");
this.userService = (UserService) context.getBean("userService");
}
@Test
public void countAll() {
System.out.println("数据库中的记录条数:" + userService.countAll());
}
@Test
public void insert() {
User user = new User();
user.setUsername("苏若年");
user.setPassword("passtest");
user.setEmail("dennisit@163.com");
user.setSex("男");
user.setAge(23);
userService.insert(user);
}
@Test
public void selectAll() {
List<User> list = userService.selectAll();
for (int i = 0; i < list.size(); i++) {
User user = list.get(i);
System.out.println("用户名:" + user.getUsername() + "\t密码:"
+ user.getPassword() + "\t邮箱:" + user.getEmail());
}
}
@Test
public void update() {
User user = new User();
user.setUsername("苏若年");
user.setPassword("xxxxxxxx");
user.setEmail("xxxxxx@163xxx");
user.setSex("男");
user.setAge(23);
userService.update(user);
}
@Test
public void delete() {
userService.delete("苏若年");
}
@Test
public void findByName() {
User user = userService.findByUserName("刘浩11");
System.out.println("用户名:" + user.getUsername() + "\t密码:"
+ user.getPassword() + "\t邮箱:" + user.getEmail());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
test.rar (37个子文件)
test
pom.xml 3KB
config
log4j.properties 2KB
com
liuhao
dao
UserDao.xml 1KB
MyBatis-Configuration.xml 266B
applicationContext.xml 1KB
target
test-classes
m2e-jee
web-resources
META-INF
maven
test
test
pom.xml 3KB
pom.properties 201B
MANIFEST.MF 105B
classes
log4j.properties 2KB
com
liuhao
dao
UserDao.class 420B
UserDao.xml 1KB
test
SpringBatis.class 3KB
service
UserService.class 432B
impl
UserServiceImpl.class 1KB
entity
User.class 1KB
MyBatis-Configuration.xml 266B
applicationContext.xml 1KB
test
com
liuhao
test
SpringBatis.java 2KB
.settings
org.eclipse.m2e.core.prefs 90B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 450B
org.eclipse.core.resources.prefs 77B
org.eclipse.wst.common.component 707B
org.eclipse.wst.common.project.facet.core.prefs.xml 161B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.validation.prefs 50B
.jsdtscope 522B
org.eclipse.jdt.core.prefs 430B
src
com
liuhao
dao
UserDao.java 335B
service
UserService.java 343B
impl
UserServiceImpl.java 916B
entity
User.java 895B
.project 1KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 1024B
classes
lib
index.jsp 829B
.classpath 973B
共 37 条
- 1
资源评论
- qq14591454652016-11-26的确是够简单。少了一个依赖: <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> <version>1.6</version> </dependency>
- 香腮边轻轻滑过2017-11-16不错的资源
- kloseking2017-03-25不错的资源,有帮助
- junquinchen2016-05-20不错的资源,有帮助
- EricLiang2020-08-05不错的资源,有帮助
hoxis
- 粉丝: 787
- 资源: 45
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功