springboot+jpa Use custom configuration file to connect to database and report an error :Cannot determine embedded database driver class for database type NONE

reason : No data source configured dataSource, The configuration file is loaded in .

terms of settlement : Configure the data source in the configuration class

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") In higher version @ConfigurationProperties In addition to the locations Properties of  
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 More articles about

  1. solve spring-boot Problems in startup :Cannot determine embedded database driver class for database type NONE

    problem as follows : 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. thorough Spring Boot: How to investigate 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 Client startup error Cannot determine embedded database driver class for database type NONE

    With this kind of database configuration, you can't connect to the database Tips :Cannot determine embedded database driver class for database type NONE Solution : Qi ...

  5. Springboot Project start error , Tips Cannot determine embedded database driver class for database type NONE

    I am here springboot Database configuration is introduced into the project : <dependency> <groupId>org.mybatis.spring.boot</groupId> ...

  6. spriing boot Initiate error reporting :Cannot determine embedded database driver class for database type NONE

    I've been learning to use spring boot. Use maven Create a good project , Just quote what you need to use spring boot dependent jar package , There's no other configuration . I wrote the simplest example , As shown below : package com ...

  7. 【spring cloud】【spring boot】 Project start error :Cannot determine embedded database driver class for database type NONE

    Solve the reference article :https://blog.csdn.net/hengyunabc/article/details/78762097 spring boot The startup error is as follows : Error starting A ...

  8. SpringBoot Project report error Cannot determine embedded database driver class for database type NONE

    reason : Cannot determine embedded database driver class for database type NONE This is because spring boot It will load by default org.s ...

  9. Report errors Cannot determine embedded database driver class for database type NONE resolvent

    Because I don't need a database , start-up springboot Report errors : Cannot determine embedded database driver class for database type NONE If ...

Random recommendation

  1. add add to

    s = {1,2,3,4,5,6,}  To add data ! s = {1,2,3,4,5,6,} s.add('s')# Add string 's' s.add('3')# Add string '3' s.add(3)# add to 3 He Zi ...

  2. sys/types.h fcntl.h unistd.h sys/stat.h

    sys/types.h yes Unix/Linux The header file of the basic system data type of the system , contain size_t,time_t,pid_t Other types . Include... In the application source file <sys/types.h> To visit ...

  3. 【 Ali gather security &#183; Safety weekly 】 Behind the double 11 “ Bully - Seven layer flow cleaning ” System | Dajiang VS “ amateur ”, Who threatened who ?

    key word : Bully - Seven layer flow cleaning system VS " amateur " Snap up software " The first case " Enterprise safety construction Aadhaar Data leakage North Korea APT organization Lazarus 丨 31 Illegal payment A ...

  4. java Related knowledge

    Java Basics . grammar 1. sketch Java Cross platform principle 2. Java The security of 3. Java Three major versions 4. What is? JVM? What is? JDK? What is? JRE? 5. Java Three annotation types 6. 8 Basic data types ...

  5. Latex: extra alignment tab has been changed to cr

    Reference resources : Error: extra alignment tab has been changed to \cr Latex: extra alignment tab has been changed t ...

  6. Write in a overloaded way Python Of get request

    #encoding=utf-8#__author__="Lanyangyang" import unittestimport requestsimport json # This ...

  7. combination IdentityServer4 To configure Ocelot Of Json Profile management updates

    Ocelot Provides AddAdministration Method to set the configuration route and authorization mode services.AddOcelot().AddAdministration("/admin", ...

  8. Java Exception handling in : When to throw an exception , When to catch an exception , When to handle exceptions ?

    Java Exception handling in : When to throw an exception , When to catch an exception ? 2017-06-07 1 Anomaly classification Throwable Objects can be divided into two groups : One group is unchecked abnormal , Exception handling mechanisms are often not used for this set of exceptions , Include : Er ...

  9. Get along well with X-CTR100 l STM32 l STM32F4 l Bluetooth serial communication

    I make wheels , You make cars , Makers build it together ! More about Tucker innovation [ Tuck community www.xtark.cn ][ Tucker blog www.cnblogs.com/xtark/ ]      Bluetooth serial communication module ,X-CTR100 control ...

  10. Android And AppWidget

    1.Widget Design steps There are three things that need to be changed XML, One class: 1) first xml It's the layout XML file ( Such as :main.xml), This is it widget Of . Generally speaking, if you use this part to display the time , It's only in this layout XML in ...