整合mybatis步骤
/*** * 整合mybatisplus * 1,导入依赖, * <dependency> * <groupId>com.baomidou</groupId> * <artifactId>mybatis-plus-boot-starter</artifactId> * <version>3.2.0</version> * </dependency> * 2,配置 * 1配置数据源 * 1导入数据库驱动 * 2在application.yml中配置数据源相关信息 * 2配置mybatis-plus * 1使用MapperScan * 2告诉mybatis-plus,sql映射文件位置 */
application.yml配置。注意,要添加characterEncoding=utf-8,否则后面数据库数据会中文乱码
spring: datasource: username: root password: root url: jdbc:mysql://192.168.56.10:3306/gulimall_pms?serverTimezone=GMT%2B8&characterEncoding=utf-8 driver-class-name: com.mysql.jdbc.Driver mybatis-plus: mapper-locations: classpath:/mapper/**/*.xml #设置主键自增 global-config: db-config: id-type: auto server: port: 10000
端口占用:
coupon7000
member8000
order9000
product10000
ware11000
这样的好处是,比如扩展coupon,端口就是7xxx