Spring Boot集成flyway中遇到的问题

问题一

使用flyway中总是提示flyway插件为引入,但pom中已经放入了
最后在网上找了一圈没发现需要放入数据库连接的各种信息
如果在URL后不加入

?serverTimezone=UTC

则会出现错误:

The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone.

完整代码:


	org.flywaydb
	flyway-maven-plugin
	
		root
		password
		com.mysql.cj.jdbc.Driver
		jdbc:mysql://127.0.0.1:3306/db?serverTimezone=UTC
		true
		
		classpath:db/migration/
	

问题二

flyway成功运行了,数据库也出现了相应的table
但控制台出现这个错误,虽然看着好像不会有什么影响

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example.SimpleSystem:mall:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: net.sf.json-lib:json-lib:jar:jdk15 -> duplicate declaration of version 2.4 @ line 110, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: commons-beanutils:commons-beanutils:jar -> duplicate declaration of version 1.7.0 @ line 116, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: commons-collections:commons-collections:jar -> duplicate declaration of version 3.1 @ line 121, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: commons-lang:commons-lang:jar -> duplicate declaration of version 2.5 @ line 126, column 15
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: net.sf.ezmorph:ezmorph:jar -> duplicate declaration of version 1.0.3 @ line 131, column 15
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] -------------------< com.example.SimpleSystem:mall >--------------------
[INFO] Building myBlog 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- flyway-maven-plugin:5.2.4:migrate (default-cli) @ mall ---
[INFO] Flyway Community Edition 5.2.4 by Boxfuse
[INFO] Database: jdbc:mysql://127.0.0.1:3306/blog (MySQL 8.0)
[INFO] Successfully validated 1 migration (execution time 00:00.033s)
[INFO] Creating Schema History table: `blog`.`flyway_schema_history`
[INFO] Current version of schema `blog`: << Empty Schema >>
[INFO] Migrating schema `blog` to version 1 - Create myUser Table
[WARNING] DB: Integer display width is deprecated and will be removed in a future release. (SQL State: HY000 - Error Code: 1681)
[INFO] Successfully applied 1 migration to schema `blog` (execution time 00:00.210s)
Sat Sep 28 17:38:29 CST 2019 WARN: Caught while disconnecting...

EXCEPTION STACK TRACE:



** BEGIN NESTED EXCEPTION ** 

javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify

STACKTRACE:

javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:129)
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
	at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
	at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
	at com.mysql.cj.protocol.a.NativeProtocol.quit(NativeProtocol.java:1319)
	at com.mysql.cj.NativeSession.quit(NativeSession.java:182)
	at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1750)
	at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:720)
	at org.flywaydb.core.internal.jdbc.JdbcUtils.closeConnection(JdbcUtils.java:97)
	at org.flywaydb.core.internal.database.base.Connection.close(Connection.java:161)
	at org.flywaydb.core.internal.database.base.Database.close(Database.java:488)
	at org.flywaydb.core.Flyway.execute(Flyway.java:1731)
	at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
	at org.flywaydb.maven.MigrateMojo.doExecute(MigrateMojo.java:35)
	at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:746)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)


** END NESTED EXCEPTION **


Sat Sep 28 17:38:29 CST 2019 WARN: Caught while disconnecting...

EXCEPTION STACK TRACE:



** BEGIN NESTED EXCEPTION ** 

javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify

STACKTRACE:

javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:129)
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
	at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
	at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
	at com.mysql.cj.protocol.a.NativeProtocol.quit(NativeProtocol.java:1319)
	at com.mysql.cj.NativeSession.quit(NativeSession.java:182)
	at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1750)
	at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:720)
	at org.flywaydb.core.internal.jdbc.JdbcUtils.closeConnection(JdbcUtils.java:97)
	at org.flywaydb.core.internal.database.base.Connection.close(Connection.java:161)
	at org.flywaydb.core.internal.database.base.Database.close(Database.java:488)
	at org.flywaydb.core.Flyway.execute(Flyway.java:1731)
	at org.flywaydb.core.Flyway.info(Flyway.java:1521)
	at org.flywaydb.maven.MigrateMojo.doExecute(MigrateMojo.java:37)
	at org.flywaydb.maven.AbstractFlywayMojo.execute(AbstractFlywayMojo.java:746)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)


** END NESTED EXCEPTION **


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.850 s
[INFO] Finished at: 2019-09-28T17:38:29+08:00
[INFO] ------------------------------------------------------------------------

但本着干掉全部BUG(其实是强迫症犯了),将其解决了
问题出在MySQL与驱动版本不匹配,换成相同版本即可

查看MySQL版本

打开命令行cmd执行以下语句

  • cd C:\Program Files\MySQL\MySQL Server 8.0
  • cd bin
  • mysql -uroot -p(密码)
  • status
    然后就能看到你的版本号了,然后在pom中指定driver的版本号即可消除这个错误

你可能感兴趣的:(Java的BUG集)