insert into student(studentid,name)
values(#{studentId},#{name})
update student
set studentid = #{studentId}, name = #{name}
where id = #{id}
delete from student
where id= #{id}
4、接着定义学生service服务接口
public interface StudentService {
public void addStudent(Student student);
public void updateStudent(Student student);
public void deleteStudentById(int id);
public List selectAllStudent();
}
5、学生service服务接口实现类
@Service
public class StudentServiceImpl implements StudentService {
@Autowired
StudentMapper studentMapper;
@Override //是否开启只读事务 传播行为 隔离级别
@Transactional(readOnly=false,propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
public void addStudent(Student student) {
System.out.println("Service服务:添加");
studentMapper.addStudent(student);
}
@Override
@Transactional(readOnly=false,propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
public void updateStudent(Student student) {
System.out.println("Service服务:修改");
studentMapper.updateStudent(student);
}
@Override
@Transactional(readOnly=false,propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
public void deleteStudentById(int id) {
System.out.println("Service服务:删除");
studentMapper.deleteStudentById(id);
}
@Override
@Transactional(readOnly=false,propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
public List selectAllStudent() {
System.out.println("Service服务:查询");
List stuList = studentMapper.selectAllStudent();
return stuList;
}
}
6、使用XML文件方式配置Spring IoC
最后在数据库中的创建表student,id主键自增
到此,已经把Spring和MyBatis整合起来了,接下你可以自己测试了
测试代码:
public class TestModel {
ApplicationContext ctx = null;
StudentService ss = null;
public TestModel() {
ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
ss = ctx.getBean(StudentService.class);
}
//添加
// @Test
public void testAddStudent() {
Student student = new Student();
student.setStudentId(16999017);
student.setName("兆光");
ss.addStudent(student);
}
//修改
// @Test
public void testUpdateStudent() {
Student student = new Student();
student.setId(4);
student.setStudentId(16999000);
student.setName("光");
ss.updateStudent(student);
}
//删除
// @Test
public void testDeleteStudent() {
ss.deleteStudentById(15);
}
//查询
@Test
public void testSelectStudent() {
List stuList = ss.selectAllStudent();
for (Student student : stuList) {
System.out.println(student.getId());
System.out.println(student.getStudentId());
System.out.println(student.getName());
}
}
}
<script language="javascript">
$(function (){
var i = 4;$(window).bind("scroll", function (event){
//滚动条到网页头部的 高度,兼容ie,ff,chrome
var top = document.documentElement.s
包冲突是开发过程中很常见的问题:
其表现有:
1.明明在eclipse中能够索引到某个类,运行时却报出找不到类。
2.明明在eclipse中能够索引到某个类的方法,运行时却报出找不到方法。
3.类及方法都有,以正确编译成了.class文件,在本机跑的好好的,发到测试或者正式环境就
抛如下异常:
java.lang.NoClassDefFoundError: Could not in
NAME: gpasswd - administer the /etc/group file
SYNOPSIS:
gpasswd group
gpasswd -a user group
gpasswd -d user group
gpasswd -R group
gpasswd -r group
gpasswd [-A user,...] [-M user,...] g
enquiry mysql version in centos linux
yum list installed | grep mysql
yum -y remove mysql-libs.x86_64
enquiry mysql version in yum repositoryyum list | grep mysql oryum -y list mysql*
install mysq
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.
Below is one possible representation of s1 = "great":
select p.spid,c.object_name,b.session_id,b.oracle_username,b.os_user_name from v$process p,v$session a, v$locked_object b,all_objects c where p.addr=a.paddr and a.process=b.process and c.object_id=b.