java – BeanCreationException:无法确定数据库类型为NONE的嵌入式数据库驱动程序类

我正在尝试运行我的程序,我总是得到这个例外:
Caused by: org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:137)
at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 45 more

我通过gradle导入所有依赖项:

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
baseName = 'flatify-backend-service'
version =  '0.1.0'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.hibernate:hibernate-core:4.3.6.Final'
compile 'javax.servlet:javax.servlet-api:3.1.0'
compile 'org.javassist:javassist:3.15.0-GA'
compile 'MysqL:mysql-connector-java:5.1.31'
compile 'commons-dbcp:commons-dbcp:1.4'
testCompile("junit:junit")
testCompile("org.springframework:spring-test")
}

task wrapper(type: Wrapper) {
gradLeversion = '2.5'
}

正如你所看到的,我正在添加mysql-connector并不是什么应该将驱动程序类添加到我的项目中?
我错过了什么吗?

我只添加到最后一个例外,因为所有其他都是由这个引起的.
如果您需要任何其他详细信息,请告知我们.

谢谢

我的Config类:

@Configuration
@EnableTransactionManagement
public class PersistenceJPAConfig {

@Bean
public LocalContainerEntityManagerfactorybean entityManagerFactory() {
    LocalContainerEntityManagerfactorybean em = new LocalContainerEntityManagerfactorybean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] { "at.flatify.persistance.entity" });

    JpavendorAdapter vendorAdapter = new HibernateJpavendorAdapter();
    em.setJpavendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());

    return em;
}


@Bean(destroyMethod = "close")
public DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("com.MysqL.jdbc.Driver");
    dataSource.setUrl("jdbc:MysqL://localhost:3306/flatify");
    dataSource.setUsername("user");
    dataSource.setPassword("password");

    return dataSource;
}

@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf){
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(emf);

    return transactionManager;
}

@Bean
public PersistenceExceptionTranslationPostProcessor exceptionTranslation(){
    return new PersistenceExceptionTranslationPostProcessor();
}

Properties additionalProperties() {
    Properties properties = new Properties();
    properties.setProperty("hibernate.hbm2ddl.auto","create-drop");
    properties.setProperty("hibernate.dialect","org.hibernate.dialect.MysqL5Dialect");
    return properties;
}

}

解决方法

Spring启动无法确定要使用的驱动程序.您需要在某处指定以下属性: spring.datasource.driverClassName 您还需要指定其他属性,请查看文档.

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...