Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using spring-boot 2.0.2.RELEASE and FlyWay is not running. No errors

I have a very simple setup, brand new project, and for some reason Flyway never initialises. There are no errors. I've spent several hours trying to figure what I've done wrong, to no avail.

Further, I've done a nearly identical setup on another project using Spring Boot version 1.4.2.RELEASE. The only difference is that the Flyway configuration in the application.yml is now under the "spring" context, instead of being at the root.

If anybody can see what I've missed, or a typo or something, I would greatly appreciate it.

I also tried commenting out the flyway specific datasource config so it would just use the spring datasource, but that made no difference.

Thanks, Tonya

pom.xml (relevant portions):

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
</parent>

<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
</dependency>

application.yml (relevant portion)

spring.profiles: default

spring:
    flyway:
        url: jdbc:mysql://localhost:3306/test_schema?tinyInt1isBit=false
        user: adminuser
        password: adminuser

    datasource:
        url: jdbc:mysql://localhost:3306/test_schema?tinyInt1isBit=false
        username: restricteduser
        password: restricteduser
        driver-class-name: com.mysql.jdbc.Driver

    jpa:
        database: MYSQL
        hibernate.ddl-auto: none
        show-sql: true
        properties.hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect

DB setup script:

CREATE SCHEMA `test_schema`;

CREATE USER IF NOT EXISTS 'restricteduser'@'%' IDENTIFIED BY 'restricteduser';
GRANT SELECT,INSERT,UPDATE,DELETE ON test_schema.* TO 'restricteduser'@'%' WITH GRANT OPTION;

CREATE USER IF NOT EXISTS 'adminuser'@'%' IDENTIFIED BY 'adminuser';
GRANT ALL PRIVILEGES ON test_schema.* TO 'adminuser'@'%' WITH GRANT OPTION;
GRANT SUPER ON *.* TO 'adminuser'@'%';
FLUSH PRIVILEGES;

src -> main -> resources -> db -> migration -> V1__create_test_schema.sql

DROP TABLE IF EXISTS `testing`;
CREATE TABLE `testing` (
  `id` VARCHAR(50) NOT NULL,
  `test_string` VARCHAR(50) NOT NULL,
  PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2;

the log output:

2018-05-17 09:27:46.498  INFO 55086 --- [           main] ilmn.vqs.VqsApplication                  : Starting VqsApplication on ussd-olm-016438 with PID 55086 (/Users/tohrel/projects/variant-query-service/target/classes started by tohrel in /Users/tohrel/projects/variant-query-service)
2018-05-17 09:27:46.502  INFO 55086 --- [           main] ilmn.vqs.VqsApplication                  : The following profiles are active: default
2018-05-17 09:27:46.547  INFO 55086 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@33c911a1: startup date [Thu May 17 09:27:46 PDT 2018]; root of context hierarchy
2018-05-17 09:27:47.636  INFO 55086 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8090 (http)
2018-05-17 09:27:47.659  INFO 55086 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-05-17 09:27:47.659  INFO 55086 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-05-17 09:27:47.663  INFO 55086 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/tohrel/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-05-17 09:27:47.730  INFO 55086 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-05-17 09:27:47.731  INFO 55086 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1183 ms
2018-05-17 09:27:48.002  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-05-17 09:27:48.002  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-05-17 09:27:48.002  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-05-17 09:27:48.002  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-05-17 09:27:48.003  INFO 55086 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-05-17 09:27:48.003  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpTraceFilter' to: [/*]
2018-05-17 09:27:48.003  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-05-17 09:27:48.003  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-05-17 09:27:48.095  INFO 55086 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-17 09:27:48.279  INFO 55086 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@33c911a1: startup date [Thu May 17 09:27:46 PDT 2018]; root of context hierarchy
2018-05-17 09:27:48.327  INFO 55086 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-05-17 09:27:48.328  INFO 55086 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-05-17 09:27:48.346  INFO 55086 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-17 09:27:48.346  INFO 55086 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-17 09:27:48.933  INFO 55086 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@70f822e, org.springframework.security.web.context.SecurityContextPersistenceFilter@1abfe081, org.springframework.security.web.header.HeaderWriterFilter@52d6cd34, org.springframework.security.web.csrf.CsrfFilter@65753040, org.springframework.security.web.authentication.logout.LogoutFilter@17b6d426, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@5e2a3040, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@5c1f6d57, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@5bb51241, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@c2e3264, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4492eede, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3efedc6f, org.springframework.security.web.session.SessionManagementFilter@27b2faa6, org.springframework.security.web.access.ExceptionTranslationFilter@61d84e08, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@3872bc37]
2018-05-17 09:27:48.966  INFO 55086 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-05-17 09:27:48.973  INFO 55086 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@168cd36b: startup date [Thu May 17 09:27:48 PDT 2018]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@33c911a1
2018-05-17 09:27:49.006  INFO 55086 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'handlerExceptionResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration; factoryMethodName=handlerExceptionResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.web.servlet.WebMvcEndpointChildContextConfiguration; factoryMethodName=compositeHandlerExceptionResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfiguration.class]]
2018-05-17 09:27:49.033  INFO 55086 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8091 (http)
2018-05-17 09:27:49.034  INFO 55086 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-05-17 09:27:49.034  INFO 55086 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-05-17 09:27:49.041  INFO 55086 --- [ost-startStop-1] o.a.c.c.C.[Tomcat-1].[localhost].[/]     : Initializing Spring embedded WebApplicationContext
2018-05-17 09:27:49.041  INFO 55086 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 68 ms
2018-05-17 09:27:49.057  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-05-17 09:27:49.057  INFO 55086 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-05-17 09:27:49.068  INFO 55086 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path ''
2018-05-17 09:27:49.076  INFO 55086 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/healthcheck],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-05-17 09:27:49.093  INFO 55086 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public java.util.Map<java.lang.String, java.lang.Object> org.springframework.boot.actuate.autoconfigure.web.servlet.ManagementErrorEndpoint.invoke(org.springframework.web.context.request.ServletWebRequest)
2018-05-17 09:27:49.097  INFO 55086 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-17 09:27:49.097  INFO 55086 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-17 09:27:49.106  INFO 55086 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@168cd36b: startup date [Thu May 17 09:27:48 PDT 2018]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@33c911a1
2018-05-17 09:27:49.158  INFO 55086 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8091 (http) with context path ''
2018-05-17 09:27:49.167  INFO 55086 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8090 (http) with context path ''
2018-05-17 09:27:49.169  INFO 55086 --- [           main] ilmn.vqs.VqsApplication                  : Started VqsApplication in 3.075 seconds (JVM running for 3.81)
2018-05-17 09:27:49.670  INFO 55086 --- [on(8)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-05-17 09:27:49.670  INFO 55086 --- [on(8)-127.0.0.1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-05-17 09:27:49.684  INFO 55086 --- [on(8)-127.0.0.1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 14 ms
like image 990
Nephthys76 Avatar asked May 17 '18 16:05

Nephthys76


1 Answers

I was able to get FlyWay to run as expected by adding a "locations" configuration to the application.yml... like so:

spring:
    flyway:
        url: jdbc:mysql://localhost:3306/test_schema?tinyInt1isBit=false
        user: adminuser
        password: adminuser
        locations: classpath:/db/migration

According to the spring-boot documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html, I should not have had to configure that directory location

By default, they are in a folder called classpath:db/migration, but you can modify that location by setting spring.flyway.locations

Thanks for any time that anybody spent. If anybody knows why I needed to configure the location when I was using the default one, please let me know.

Thanks, Tonya

like image 138
Nephthys76 Avatar answered Nov 15 '22 12:11

Nephthys76