纯注解SSM整合(基于之前的所有的配置整合)

在这里插入图片描述
除了jdbc.properties其他的配置文件全部都要消灭掉。
接下来第一个:我们杀UserDao.xml。

public interface UserDao {

    @Insert("insert into user(userName,password,realName,gender,birthday)values(#{userName},#{password},#{realName},#{gender},#{birthday})")
    public boolean save(User user);

    @Update("update user set userName=#{userName},password=#{password},realName=#{realName},gender=#{gender},birthday=#{birthday} where uuid=#{uuid}")
    public boolean update(User user);

    @Delete("delete from user where uuid = #{uuid}")
    public boolean delete(Integer uuid);

    @Select("select * from user where uuid = #{uuid}")
    public User get(Integer uuid);

    @Select(" select * from user")
    public List<User> getAll();

    @Select("select * from user where userName=#{userName} and password=#{password}")
    public User getByUserNameAndPassword(@Param("userName") String userName, @Param("password") String password);

}

直接把映射文件里面的东西放注解上面就好了。
第二步,我们杀applicationContext.xml文件:(我们创建config文件夹并在其目录下创建主配置类,用该主配置类来部分代替applicationContext.xml)事实上因为我们在applicationContext.xml里面配置了Spring和JDBC以及MyBatis的东西,所以这个配置文件我们是使用三个配置类来替代的(SpringConfig,JdbcConfig,MyBatisConfig)
写到这里不想写了(测试已经通过了),我就直接写下配置文件对应类的关系吧你自己去ssm_annotation module下面看吧,然后是分先后顺序的哈:

  1. UserDao.xml---------------------UserDao(上面写了)
  2. applicationContext.xml---------------------SpringConfig,JdbcConfig,MyBatisConfig
  3. springMVC.xml---------------------SpringMVCConfig
  4. web.xml---------------------ServletContainersInitConfig

这样就全部替换完成了。

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值