整合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自动