整合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
整合SSM框架应用 - spring+mybatis

整合SSM框架应用 - spring+mybatis
整合SSM框架应用 - spring+mybatis
//注意
//@Resource 按照bookMapper别名称在spring容器中找装配到BookMapper属性中,如果不存在就按类型去装配。
//@Autowired按byType自动注入,而@Resource默认按 byName自动

相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2021-11-30
  • 2021-05-13
  • 2021-11-22
  • 2021-12-06
  • 2022-12-23
猜你喜欢
  • 2021-02-10
  • 2021-07-25
  • 2021-08-10
  • 2021-11-19
  • 2022-12-23
  • 2022-01-12
  • 2021-07-06
相关资源
相似解决方案