前提・実現したいこと
osはmac10.15.4
統合開発環境はSTS4
Spring Boot 2.2.6.RELEASE
ビルドツールはgradle6.3
データベースはDocker上のMySQL8.0.19(ターミナルから接続確認済み)
OpenJDK13.0.2
初期実行をするのですが、エラーが表示され先に進めず困っています。
発生している問題・エラーメッセージ
- コンソール
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. . ____ _ __ _ _ /\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ / _` | \ \ \ \ \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.2.6.RELEASE) 2020-04-18 00:59:16.334 INFO 2504 --- [ main] com.kametalk.app.MyAppApplication : Starting MyAppApplication on /MyApp) 2020-04-18 00:59:16.341 INFO 2504 --- [ main] com.kametalk.app.MyAppApplication : No active profile set, falling back to default profiles: default 2020-04-18 00:59:18.347 INFO 2504 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2020-04-18 00:59:18.399 INFO 2504 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 38ms. Found 0 JPA repository interfaces. 2020-04-18 00:59:19.424 INFO 2504 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2020-04-18 00:59:19.436 INFO 2504 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2020-04-18 00:59:19.436 INFO 2504 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33] 2020-04-18 00:59:19.621 INFO 2504 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2020-04-18 00:59:19.621 INFO 2504 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3123 ms 2020-04-18 00:59:19.733 WARN 2504 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver 2020-04-18 00:59:19.737 INFO 2504 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2020-04-18 00:59:19.793 INFO 2504 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-04-18 00:59:19.854 ERROR 2504 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver ※続きあり
- build.gradle
plugins { id 'org.springframework.boot' version '2.2.6.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'java' } group = 'com.kametalk.app' version = '0.0.1-SNAPSHOT' sourceCompatibility = '${java_version}' repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly group: 'mysql', name: 'mysql-connector-java', version: '${mysql_version}' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } } test { useJUnitPlatform() }
- application.properties
#データベース spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/myapp_db spring.datasource.username=root spring.datasource.password=root spring.datasource.sql-script-encoding=utf-8 spring.jpa.database=MYSQL #サーバー
試したこと
- mysql-connector-java-8.0.19.jarが依存関係にダウンロードされたいなかったので、自らダウンロードして直接jarを指定してみたがエラー内容は変わらずでした。
- javaのビルドバージョンを変更してみたが変わらずでした。
- driver-class-nameをdriverClassNameに変更してみたり、com.mysql.cj.jdbc.Driverをcom.mysql.jdbc.Driverに変更してみたが変わらずでした。
- OpenJDK13がダメなのかと思い色々調べるも、まだ勉強中なため分かりませんでした。
どなたかお助けください。
お願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。