質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Apache Maven

Apache Mavenは、ソフトウェアプロジェクトの管理ツールです。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

Q&A

解決済

2回答

12456閲覧

mvnw spring-boot:run でエラーが起きて起動できない

shibuchaaaan

総合スコア19

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Apache Maven

Apache Mavenは、ソフトウェアプロジェクトの管理ツールです。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

0グッド

0クリップ

投稿2019/04/26 08:46

編集2019/04/26 08:47

前提・実現したいこと

Spring公式ガイドの通りにSpringBootからMySQLへの接続を試してみようと思い、公式からプロジェクトのGitをcloneしました。

Mavenから起動させようと、コマンドで
mvnw spring-boot:run (mvn spring-boot:run)
を打ったところエラーが起きて起動できないので、解決方法を知りたいです。

環境

  • Apache Maven 3.6.1
  • Java version: 10.0.1
  • jdk-10.0.1
  • windows 10

発生している問題・エラーメッセージ

mvnw spring-boot:runした時

C:\Users\user-\Desktop\pleiades\workspace\complete>mvnw spring-boot:run Unzipping C:\Users\user-.m2\wrapper\dists\apache-maven-3.3.9-bin\2609u9g41na2l7ogackmif6fj2\apache-maven-3.3.9-bin.zip to C:\Users\user-.m2\wrapper\dists\apache-maven-3.3.9-bin\2609u9g41na2l7ogackmif6fj2 Exception in thread "main" java.util.zip.ZipException: zip END header not found at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1527) at...(略)

この時、zipファイルが開けないといった感じのエラーのようだったので、
よくネット上で書かれている
mvn spring-boot:run
でやってみることにしました。
→エラー

C:\Users\user-\Desktop\pleiades\workspace\complete>mvn spring-boot:run [INFO] Scanning for projects... [INFO] [INFO] -----------------< org.springframework:gs-mysql-data >------------------ [INFO] Building gs-mysql-data 0.1.0 [INFO] --------------------------------[ jar ]--------------------------------- ... (中略) Downloading ~~~ Spring起動 ... 2019-04-26 16:19:08.203 ERROR 17980 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. java.sql.SQLException: The server time zone value '???????? (??W????????)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.15.jar:8.0.15] at.....(何十行も続く) 2019-04-26 16:19:08.410 WARN 17980 --- [ main] o.s.b.a.orm.jpa.DatabaseLookup : Unable to determine jdbc url from datasource org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta-data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: The server time zone value '???????? (??W????????)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:328) ~[spring-jdbc-5.1.6.RELEASE.jar:5.1.6.RELEASE] at....(略) Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '???????? (??W????????)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na] at...(略) 2019-04-26 16:19:11.127 ERROR 17980 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. java.sql.SQLException: The server time zone value '???????? (??W????????)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.15.jar:8.0.15] at....(略) 2019-04-26 16:19:11.315 WARN 17980 --- [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : HHH000342: Could not obtain connection to query metadata : The server time zone value '???????? (??W????????)' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. 2019-04-26 16:19:11.372 WARN 17980 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-04-26 16:19:11.478 ERROR 17980 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE] at....(略) [WARNING] java.lang.reflect.InvocationTargetException at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at....(略) Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService (AbstractServiceRegistryImpl.java:275) at....(略) Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect (DialectFactoryImpl.java:100) at....(略) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 45.662 s [INFO] Finished at: 2019-04-26T16:19:12+09:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.4.RELEASE:run (default-cli) on project gs-mysql-data: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Spring Bootアプリケーションの目的:

  • SpringBootとMySQLの接続
  • データの挿入と取り出し

ソースコード

https://github.com/spring-guides/gs-accessing-data-mysql.git
をcloneして、application.property(データベース接続の設定)だけ変えたものです。

application.property

1spring.jpa.hibernate.ddl-auto=create 2spring.datasource.url=jdbc:mysql://localhost:3307/db_spring 3spring.datasource.username=user 4spring.datasource.password=####

usernameとpasswordはここでは隠していますが、正しいものを入れています。

試したこと

MariaDB [(none)]> show full processlist; +----+------+-----------------+------+---------+------+-------+-----------------------+----------+ | Id | User | Host | db | Command | Time | State | Info | Progress | +----+------+-----------------+------+---------+------+-------+-----------------------+----------+ | 10 | root | localhost:54365 | NULL | Query | 0 | init | show full processlist | 0.000 | +----+------+-----------------+------+---------+------+-------+-----------------------+----------+

https://mvnrepository.com/artifact/com.zaxxer/HikariCP/3.3.1からダウンロードしたHikariCP-3.3.1.jarを該当プロジェクトのtargetフォルダ内に置き、
mvn clean packageしてから再度
mvn spring-boot:runしましたが変わりませんでした。

公式ガイドのGitをcloneしているのでソースコードが間違っているとは考えにくいです。
原因と解決策が分からず、何か分かる方がいらっしゃればご教授いただきたいです。
よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

投稿2019/04/26 13:13

wtokuno

総合スコア448

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

shibuchaaaan

2019/04/27 04:28

ありがとうございます!試してみます!
guest

0

ベストアンサー

いくつか手順でやっていないものがあるようですが、以下の手順でできましたのでお試しください。

(1) https://github.com/spring-guides/gs-accessing-data-mysql.git からリポジトリをクローン

(2) クローンしたディレクトリで、docker-compose up を実行する(別途dockerのインストールが必要)
→これで実行に必要なMySQLがDockerに構築される。

(3) SpringToolSuiteにて、mavenプロジェクトとしてクローンしたリポジトリをインポートする。
※(2)(3)の順序はどちらでもいい

(4) インポートしたプロジェクトで、mvn install を行いビルドする。

(5) src/main/java 内にある hello/Application.java を選択し、実行する

(6) http://127.0.0.1:8080/demo/all で検索結果を表示、http://127.0.0.1:8080/demo/add?name=abc&email=sample@email.com などで、データ登録が確認できる

投稿2019/04/26 11:56

A-pZ

総合スコア12011

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

shibuchaaaan

2019/04/27 04:27

dockerが必要だったんですね…!ありがとうございます、これで試してみます!
shibuchaaaan

2019/04/29 09:50

おっしゃる通りにやったらできました!ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問