使用Springboot实现简单的增删改查-超详细

时间:2025-02-15 20:15:12

修改数据库配置,application-properties是项目默认的配置文件。这里把它重命名为(也可以删除掉)。我们使用yml的文件作为项目配置文件。
8.1 新建和文件。在中写入如下代码。

spring:
  profiles:
    active: dev

  thymeleaf:
    view-names: /*
    cache: false
    prefix: /WEB-INF/html

8.2 在application-dev写入如下代码,注意mapper-locations: classpath:对应的路径名字就是以后在resources下创建的文件夹的名字

server:
  port: 8888

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://localhost:3306/zls?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
    driver-class-name: 

mybatis:
  mapper-locations: classpath:mappers/*
  type-aliases-package: 

#showSql
logging:
  level:
    com:
      example:
        mapper : debug