package cn.lxz.test;
import cn.lxz.dao.StudentDao;
import cn.lxz.domain.Student;
import cn.lxz.service.StudentService;
import cn.lxz.service.impl.StudentServiceImpl2;
import cn.lxz.utils.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.ArrayList;
import java.util.List;
public class SpringTest {
private final Logger logger = Logger.getLogger(SpringTest.class);
@Test
public void test() {
System.out.println("你好啊");
}
// 查询所有的数据
@Test
public void listTest() {
SqlSession sqlSession = null;
List<Student> students = new ArrayList<Student>();
try {
sqlSession = MyBatisUtil.createSqlSession();
students=sqlSession.getMapper(StudentDao.class).list();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally{
MyBatisUtil.closeSqlSession(sqlSession);
}
for(Student s: students){
logger.debug(s.toString());
}
for(Student bill: students){
System.out.println(bill.toString());
}
}
//插入一条数据
@Test
public void insertTest() {
ApplicationContext context=new ClassPathXmlApplicationContext("Spring-context.xml");
StudentService service=(StudentService)context.getBean("studentService2");
System.out.println(service);
// System.out.println(studentServiceImpl2.list());
System.out.println(service.addStudent(new Student(null,"王公公","女")));
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Spring的AOP实现的日志功能案例.zip
共28个文件
class:8个
java:8个
xml:7个
需积分: 12 1 下载量 168 浏览量
2023-03-09
09:05:13
上传
评论
收藏 25KB ZIP 举报
温馨提示
当添加Studnet的信息的时候实现日志的插入 Spring的AOP实现的日志功能案例.zip Spring的AOP实现的日志功能案例.zip Spring的AOP实现的日志功能案例.zip Spring的AOP实现的日志功能案例.zip Spring的AOP实现的日志功能案例.zip Spring的AOP实现的日志功能案例.zip Spring的AOP实现的日志功能案例.zip Spring的AOP实现的日志功能案例.zip
资源推荐
资源详情
资源评论
收起资源包目录
Spring的AOP实现的日志功能案例.zip (28个子文件)
log.log 0B
pom.xml 645B
src
test
java
cn
lxz
test
SpringTest.java 2KB
main
resources
mapper
StudentDao.xml 468B
mybatis-config.xml 1KB
Spring-context.xml 2KB
log4j.properties 2KB
database.properties 182B
java
cn
lxz
utils
MyBatisUtil.java 1001B
dao
StudentDao.java 195B
service
StudentService.java 209B
impl
StudentServiceImpl2.java 1KB
StudentServiceImpl.java 1KB
aop
UserServiceLogger.java 1KB
domain
Student.java 269B
target
classes
mapper
StudentDao.xml 468B
cn
lxz
utils
MyBatisUtil.class 2KB
dao
StudentDao.class 264B
service
StudentService.class 276B
impl
StudentServiceImpl.class 2KB
StudentServiceImpl2.class 2KB
aop
UserServiceLogger.class 2KB
domain
Student.class 2KB
mybatis-config.xml 1KB
Spring-context.xml 2KB
log4j.properties 2KB
database.properties 182B
test-classes
cn
lxz
test
SpringTest.class 3KB
generated-test-sources
test-annotations
generated-sources
annotations
共 28 条
- 1
资源评论
简单点了
- 粉丝: 400
- 资源: 77
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功