mybatis升级mybatis-plus

application.yml

server:
  port: 8080
  servlet:

spring:
  thymeleaf:
    prefix: classpath:/templates/
    cache: false
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/master?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=UTC
    username: root
    password: root



#mybatis:
#  mapper-locations: classpath*:mappers/system/*.xml
#  type-aliases-package: com.xl.xinliao.system.entity
mybatis-plus:
  mapper-locations: classpath*:mappers/system/*.xml
  type-aliases-package: com.xl.xinliao.system.entity


#logging:
#  config: classpath:xl-logback.xml
#  path: logfys
logging:
  level:
    root: warn
    com.xl.xinliao.system.dao: trace
  pattern:
    console: "%p%m%n"

pom.xml 升级mybatis-plus要先把先前的mybatis注释掉


        
            mysql
            mysql-connector-java
        

        
        

        
            com.baomidou
            mybatis-plus-boot-starter
            3.1.1
        
        
        
            org.projectlombok
            lombok
            1.16.14
            provided
        

启动类

@SpringBootApplication
@MapperScan("com.xl.xinliao.system.dao")
public class XinliaoApplication {
    public static void main(String[] args) {
        SpringApplication.run(XinliaoApplication.class, args);
        }
 }

spring boot项目结构和之前的spring mvc差不多
也是mybatis升级mybatis-plus_第1张图片
@Controller
@RequestMapping("/login")
public class LoginController {
}

public interface LoginMapper extends BaseMapper {

}

mybatis-plus读数据库的时候下划线自动转成驼峰形式的。便于在页面显示

@Data
@TableName(“login”)
public class Login extends Model {
private static final long serialVersionUID = 1L;
@TableId(value = “id”, type = IdType.AUTO)
private long Id;//
}

public interface ILoginService extends IService {}

@Service
public class LoginServiceImpl extends ServiceImpl implements ILoginService {}

简单的分层

你们的观看是我前进的动力,这个是我最近从mybatis升级mybatis-plus的一些操作,其中也遇到很多毛病

多谢支持

你可能感兴趣的:(mybatis-plus)