前提・実現したいこと
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はここでは隠していますが、正しいものを入れています。
試したこと
- Help 1を見ましたが、分かりませんでした…。
- Hikaripoolが怪しいと思い、コネクションプーリングが効かない問題をコードリーディングから解決したお話を参考にプロセスを調査しましたが1個しか表示されず、記事のように10個いっぱいという現象ではないです。
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しているのでソースコードが間違っているとは考えにくいです。
原因と解決策が分からず、何か分かる方がいらっしゃればご教授いただきたいです。
よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/27 04:28