【SpringBoot】SpringBoot整合Mybatis-Plus、热部署

热部署

添加devtools就可以实现热部署,以前在springmvc时期,每次调整完代码都要重新运行才可以,说实话好烦的。

<!--devtools依赖-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>

只要你每次修改完代码,boot会重新帮你启动,省去了比较多的麻烦。

修改端口

springboot默认是8080端口,访问路径是/,那如果我们平时想修改怎么办。可以在application.properties或者yml文件中添加如下的东西。

#端口
server.port=80
#项目访问根路径(server.servlet.context-path过时了)
server.servlet.context-path=/

日志输出

SpringBoot默认的日志框架为logback,是log4j作者的做的新一代的日志框架,性能更好。

SpringBoot与Mybatis-plus整合

<!--MySQL驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!--druid连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.10</version>
        </dependency>
        <!--mybatis-plus-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.2.0</version>
        </dependency>

yml配置中添加如下:

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/stu_score
    username: root
    password: 123456
    druid:
      max-active: 20
      min-idle: 10
      initial-size: 5
      pool-prepared-statements: true
      max-pool-prepared-statement-per-connection-size: 20

默认支持驼峰配置。

Application启动类加@MapperScan(“com.gaby.boot.mapper”) 注解 以及yml配置中添加mapper.xml的路径

@SpringBootApplication
@ComponentScan(basePackages="com.gaby.boot")
@MapperScan("com.gaby.boot.mapper")
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
mybatis-plus:
  mapper-locations: ['classpath:com/gaby/boot/mapper/xml/*.xml']
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杰肥啊

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值