解决方法 If you want an embedded database (H2, HSQL or Derby), please put it on the classpath

本文档介绍了在Springboot2.5.1中集成mybatis-plus-boot-starter3.3.2时遇到的错误及解决方案。错误提示表明数据库连接配置不正确。解决方法包括更新`application.yml`文件中的数据库连接配置,添加相关依赖,并展示了MybatisPlusConfig配置。同时,提供了完整的项目依赖和pagehelper配置。
摘要由CSDN通过智能技术生成

场景

Springboot 2.5.1集成 mybatis-plus-boot-starter 3.3.2 报错

Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).


Process finished with exit code 1

解决方法 

#spring:
#  datasource:
#  druid:
#      url:
#      username: root
#      password: 123456
#      driver-class-name: com.mysql.cj.jdbc.Driver

# 替换为:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/datapro?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456

相关环境配置

        <!-- mybatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.13</version>
        </dependency>
        <!--        自动代码生成器-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.4.1</version>
        </dependency>
<!--        添加 模板引擎 依赖,MyBatis-Plus 支持 Velocity(默认)-->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.31</version>
        </dependency>
<!--        分页插件-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.12</version>
        </dependency>

MybatisPlusConfig配置

@Configuration
@MapperScan("com.data.xxx.dao")
public class MybatisPlusConfig {

}

application.yml配置

#spring:
#  datasource:
#  druid:
#      url:
#      username: root
#      password: 123456
#      driver-class-name: com.mysql.cj.jdbc.Driver

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/datapro?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456

mybatis-plus:
    mapper-locations: classpath:mappers/*.xml
    type-aliases-package: com.data.xxx.entity
    configuration:
        log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

pagehelper:
  helper-dialect: mysql
  reasonable: true
  support-methods-arguments: true
  pageSizeZero: true
  params: count=countSql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值