Weste
Weste

Reputation: 79

Unable to Build Spring Boot Project with Flyway and Test Class

I have added flyway to our spring boot java application. The only way I can successfully build the project with maven is to comment out the test class. Otherwise I receive a flyway error when flyway encounters a SQL script that is attempting to create indexes within a Create Table script. The errors are below: Caused by: org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException: Message : Unknown data type: "IDK_COMPANIES_CITY"; SQL statement: How can I get my project to build without commenting out the tests? The test class is below: Note: I can comment out the Test class, build and deploy the project successfully. All the SQL scripts migrate successfully. The application is using a MariaDB in the cloud. Thanks.

package com.spring.sample;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = DatabaseTestApplication.class)
@WebAppConfiguration
public class DatabaseTestApplicationTests {

    @Test
    public void contextLoads() {
    }

}

Upvotes: 1

Views: 1240

Answers (1)

Thomas Kåsene
Thomas Kåsene

Reputation: 5449

I assume you're using an in-memory database in your tests, rather than connecting to a live one. That could mean that the in-memory database that is being created when your tests are run does not support the syntax inside your Flyway-scripts.

Try setting this in your test application properties:

spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQLDialect

The reason I suggest using MySQLDialect is that there is none for MariaDB and because it says so in MariaDB's Knowledge Base.

If the above doesn't work, try this property instead:

spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect

Upvotes: 1

Related Questions