springboot+jpa使用自定义配置文件连接数据库报错:Cannot determine embedded database driver class for database type NONE

原因:没有配置数据源dataSource,配置文件加载进来了的。

解决办法:在配置类中配置数据源

package com.springboot1.util;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Configuration
@PropertySource(value={"classpath:jdbc.properties"})
@ConfigurationProperties(prefix="database",ignoreUnknownFields = false)
@Component
//@ConfigurationProperties(prefix="database",locations="classpath:jdbc.properties")高版本中@ConfigurationProperties去除了locations的属性  
public class PropertyConfig {
private String driverName=null;
private String url=null;
private String username=null;
private String password=null;
public String getDriverName() {
    return driverName;
}
public void setDriverName(String driverName) {
    this.driverName = driverName;
}
public String getUrl() {
    return url;
}
public void setUrl(String url) {
    this.url = url;
}
public String getUsername() {
    return username;
}
public void setUsername(String username) {
    this.username = username;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}
@Bean
public DataSource druidDataSource() {
    DataSource datasource = new DataSource();
    datasource.setUrl(url);
    datasource.setUsername(username);
    datasource.setPassword(password);
    datasource.setDriverClassName(driverName);
    return datasource;
}

}

Cannot determine embedded database driver class for database type NONE的更多相关文章

  1. 解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE

    问题 如下: 2017-07-16 08:50:57.436  INFO 13524 --- [           main] c.p.p.web.PointshopWebApplication   ...

  2. Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embe

    Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationEx ...

  3. 深入Spring Boot:怎样排查 Cannot determine embedded database driver class for database type NONE

    ref:https://www.journaldev.com/13830/spring-boot-cannot-determine-embedded-database-driver-class-for ...

  4. Eureka 客户端启动报错误 Cannot determine embedded database driver class for database type NONE

    用这种数据库配置就是死活连不上数据库 提示:Cannot determine embedded database driver class for database type NONE 解决方式: 启 ...

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

    我在springboot项目里面引入了数据库的配置: <dependency> <groupId>org.mybatis.spring.boot</groupId> ...

  6. spriing boot 启动报错:Cannot determine embedded database driver class for database type NONE

    最近在学习使用spring boot.使用maven创建好工程,只引用需要用到的spring boot相关的jar包,除此之外没有任何的配置. 写了一个最简单的例子,如下所示: package com ...

  7. 【spring cloud】【spring boot】项目启动报错:Cannot determine embedded database driver class for database type NONE

    解决参考文章:https://blog.csdn.net/hengyunabc/article/details/78762097 spring boot启动报错如下: Error starting A ...

  8. SpringBoot项目报错Cannot determine embedded database driver class for database type NONE

    原因: Cannot determine embedded database driver class for database type NONE 这是因为spring boot默认会加载org.s ...

  9. 报错Cannot determine embedded database driver class for database type NONE解决方法

    由于我不需要数据库,启动springboot报错: Cannot determine embedded database driver class for database type NONE If ...

随机推荐

  1. day43 多表查询和pymysql

    复习 增删改查全语法 # 增 insert into db1.t1(字段2, 字段1, ..., 字段n)|省略 values (值2, 值1, ..., 值n)|(值1, 值2, ..., 值n)[ ...

  2. Spring MVC 自动为对象注入枚举类型

    原文地址:http://1358440610-qq-com.iteye.com/blog/2079048 如果一个对象里面有枚举类型的话,则Spring MVC是不能够直接进行注入的,因为它只实现了一 ...

  3. SD

    Offer(Tcode:VA23;Table: vbak and vbap) billing(Tcode:VF03;Table:vbrk and vbrp) Offer(quotation)-> ...

  4. css3回顾 checkbox

    <div class="checkBox"> <input type="checkbox" id="check1"> ...

  5. linux获取当前系统的时间

    #include <time.h> #include <sys/time.h> void sysLocalTime(char *str_info) { time_t times ...

  6. 【转】最近用Timer踩了一个坑,分享一下避免别人继续踩

    [转]最近用Timer踩了一个坑,分享一下避免别人继续踩 最近做一个小项目,项目中有一个定时服务,需要向对方定时发送数据,时间间隔是1.5s,然后就想到了用C#的Timer类,我们知道Timer 确实 ...

  7. xbee无线通讯终端

    无线数传电台支持DIGI全系列无线数传模块,包括有xbee/xbee PRO S1.xbee/xbee PRO S2C.xbee WIFI.xbee PRO S3B.xbee/xbee PRO SX( ...

  8. 《Linux就该这么学》今天开课了-Linux的发展,起源

    秦时明月当中的经典语录:失败的人只有一种,就是在抵达成功之前放弃的人——盖聂 想到这里我只想说,决定一件事,就要坚持,或许结局并不美好,但过程值得回忆

  9. Codesmith怎么判断sqlserver数据库字段是不是标识自增字段

    Codesmith怎么判断sqlserver数据库字段是不是标识自增字段 使用ExtendedProperty扩展信息判断 CS_isIdentity:是否为标识符,不支持Access CS_isCo ...

  10. tomcat的调优管理

    1 记性调整存设定. A: 方法如下: 1. linux 下编辑tomcat安装目录下的bin目录下的catalina.sh文件,windows下为catalina.bat vi  catalina. ...