Springboot项目启动报错,提示Cannot determine embedded database driver class for database type NONE

我在springboot项目里面引入了数据库的配置:

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>


        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

然后启动项目的时候报错,提示的错误信息为Cannot determine embedded database driver class for database type NONE

这是因为spring boot默认会加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类,DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean。因为工程中没有关于dataSource相关的配置信息,当spring创建dataSource bean因缺少相关的信息就会报错。

修改application.properties配置文件,添加数据库配置信息:

#jdbc configuration
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/employees?useUnicode=true&amp;characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

重新启动Springboot,就可以正常启动了。

猜你喜欢

转载自www.cnblogs.com/modou/p/10030540.html