spring4+mybatis3 集成实例(一)

阅读更多

 


 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
 xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
   
   

 
 
 
 
 
 


 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
 

 
  
  
  
 

 
 
  
  
 

 
 
 
  
 

 
 
 

 

需要加入spring-mybatis集成jar包:http://mybatis.github.io/spring/

 

@Repository
public interface UserMapper {

 public abstract int delete(String userId);
 
 public abstract int insert(User user);
 
 public abstract int update(User user);
 
 public abstract User selectById(String userId);
 
 public abstract List select();
}




 
  
  
  
  
  

  
 

 
 
  USERID, USERNAME, BIRTHDAY, SALARY
 

 
 
 

 
  insert into user
  
   
    USERID,
   

   
    USERNAME,
   

   
    BIRTHDAY,
   

   
    SALARY,
   

  

  
  
   
    #{userId},
   

   
    #{userName},
   

   
    #{birthday},
   

   
    #{salary},
   

  

 

 
 
  update user
  set USERNAME = #{userName},
   BIRTHDAY = #{birthday},
   SALARY   = #{salary}
  where USERID = #{userId}
 

 
 
  delete from user where USERID = #{userId}
 

  • spring4-mybatis3.zip (9.9 KB)
  • 下载次数: 12
  • spring4-mybatis3-lib.zip (7.6 MB)
  • 下载次数: 11

你可能感兴趣的:(spring4+mybatis3 集成实例(一))