2017-04-25 26 views
-1
@SpringBootApplication 
@Slf4j 
public class Starter { 

    public static void main(String[] args) { 
     SpringApplication.run(Starter.class, args); 
    } 
} 

とorg.h2.Driver Applicaiton.ymlは、ドライバクラスをロードできません:springboot

spring: 
    profiles: default 
    allowedIPPattern: 127.0.0.1|0:0:0:0:0:0:0:1|::1 
    jpa.hibernate.ddl-auto: validate 
    datasource: 
    driverClassName: org.h2.Driver 
    url: jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE;INIT=create schema if not exists \"public\"\; SET SCHEMA public; 

build.gradle:

buildscript { 

    repositories { 
     maven { 
      url "https://plugins.gradle.org/m2/" 
     } 
    } 

    ext.ver = [ 
      'springboot' : '1.5.3.RELEASE', 
      'slf4j': '1.7.12' 
    ] 

    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${ver.springboot}") 
     classpath "se.transmode.gradle:gradle-docker:1.2" 
    } 
} 

group 'com.mycompany' 
version '1.0-SNAPSHOT' 

apply plugin: 'java' 
apply plugin: 'org.springframework.boot' 



repositories { 
    mavenCentral() 
} 

dependencies { 
    testCompile group: 'junit', name: 'junit', version: '4.11' 
    compile("org.springframework.boot:spring-boot-starter-web:${ver.springboot}") 
    compile ('org.projectlombok:lombok:1.16.6') 
    compile("org.springframework.boot:spring-boot-starter-actuator") 
    testCompile("org.springframework.boot:spring-boot-starter-test") 
    runtime("mysql:mysql-connector-java:5.1.38") 
    runtime("org.flywaydb:flyway-core") 
    compile("com.h2database:h2") 
    compile("org.springframework.boot:spring-boot-starter-data-jpa") 
} 

エラー:

Caused by: java.lang.IllegalStateException: Cannot load driver class: org.h2.Driver 
    at org.springframework.util.Assert.state(Assert.java:70) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE] 
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:231) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE] 
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:183) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE] 
    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:42) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE] 
    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat.dataSource(DataSourceConfiguration.java:56) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_73] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_73] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_73] 
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_73] 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] 
    ... 55 common frames omitted 

任意のアイデア私は何が欠けていますか?

ymlファイルのdriverClassName:org.h2.Driver を削除しようとしました。 didnt仕事。

build.gradleとバージョンをH2に変更しようとしました。

+1

おそらくbuild.gradleのH2バージョン番号? – Mario

+0

これを変更するにはどのバージョンをお勧めしますか? – rayman

+0

特別な推奨はありません。例として、私は現在 "com.h2database:h2:1.4.194"で作業していますが、問題はありません。 – Mario

答えて

0

application.ymlからドライバ名を削除してみます。休止状態はあなたのURLからそれを拾うことができるはずです

+0

が削除されました。原因:java.lang.ClassNotFoundException:org.h2.Driver – rayman

+1

DataSourcePropertiesメソッドを見ると、ドライバが依存関係から正しくインポートされていないことを示すclassNotFoundErrorをラップしているようです。あなたがそこにそれを見つけることができるかどうかあなたの図書館をチェックしてください。 testCompileに設定することもできます – thejames42

+0

libs?私はあなたのbuild.gradeファイル – rayman

関連する問題