美文网首页
SpringMVC+Spring+Mybatis实践总结

SpringMVC+Spring+Mybatis实践总结

作者: peng66cheng | 来源:发表于2017-02-25 22:24 被阅读110次

    本文源码见https://github.com/peng66cheng/ssmDemo,请参考。

    最近开发一个后台系统,使用ssm从头搭建。这次开发,有几点值得总结,以便后续开发提高效率。(此处只提供方法,具体做法还需自行搜索)

    1、大多数dao层代码,无需手写

    1)利用mybatis-generator-core自动生成domain、dao接口、**Mapper.xml。

    2)使用org.mybatis.spring.mapper.MapperScannerConfigurer 和 @MapperScan注解,自动扫描接口注册dao。无需开发具体的dao实现类。

    3)dao接口 同 **Mapper.xml 参数映射,使用@Param注解。如果参数多于4个,则建议定义参数对象。

    参考:http://www.2cto.com/kf/201501/368973.html

    http://www.cnblogs.com/wangmingshun/p/5674633.html

    2、前端后台date类型数据传输。

    1)前端String类型转为后台Date类型,借助FormattingConversionServiceFactoryBean,编写自动转换类。

    2)后台Date类型转为前端String类型,借助@JsonFormat完成。

    参考:http://www.cnblogs.com/lcngu/p/5785805.html

    3、开发、测试、生产环境不同配置问题。

    使用maven的profile特性,完成不同配置的打包。

    (其他问题待续)

    相关文章

      网友评论

          本文标题:SpringMVC+Spring+Mybatis实践总结

          本文链接:https://www.haomeiwen.com/subject/aqjnwttx.html