整合SSM框架应用 - spring+mybatis

整合SSM框架应用

idea生产环境

spring + springmvc + mybatis(普通方式)

  • 启用devtools插件

    • settings-build-compiler->勾选build project automatically选项

    • shift+alt+ctrl+/ ->registry->勾选compiler.automake.allow.when.app.running

    • 勾选了这两项热部署才生效

    • 在springboot插件里做如下配置



      org.springframework.boot
      spring-boot-maven-plugin


      true



  • 启用安装lombok

    • settings-plugins-搜索lombok-安装lombok插件
    • @Data(@Setter,@Getter,) (Ctrl + F12 : 查看类中的方法)
    • @Data @AllArgsConstructor @NoArgsConstructor 正常使用这三个组合
    • Sttings =》 Plugins =》lombok 可以查看lombok中有那些注解
  • 一)引入mybatis

  • org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.1

二)#appliccation.xml配置数据源
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver #报红 需要去 pom.xml 中删除 runtime
url: jdbc:mysql:///testdb?useSSL=true # /// 后 / 代表127.0.0.1:3306 或者 localhost:3306
data-username: root
password:123456
#appliccation.xml 配置mybatis
mybatis:
configuration:
map-underscore-to-camel-case: true #实现自动映射 book_id => bookId , book_name => bookName
mapper-locations: classpath:mapper/*Mapper.xml #classpath带代表跟目录=》找mapper/*Mapper.xml
type-aliases-package: com.example.bootssm1.domain
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
//注意
//@Resource 按照bookMapper别名称在spring容器中找装配到BookMapper属性中,如果不存在就按类型去装配。
//@Autowired按byType自动注入,而@Resource默认按 byName自动

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值