package hu.rbr.sfinapp;

import hu.rbr.sfinapp.core.config.Config;
import org.flywaydb.core.Flyway;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;

public class FlywayRunner {

    private final Logger log = LoggerFactory.getLogger(getClass());

    private final Config config;

    @Inject
    public FlywayRunner(Config config) {
        this.config = config;
    }

    public void run() {
        log.info("Starting flyway.");

        // Create the Flyway instance
        Flyway flyway = new Flyway();

        // Point it to the database
        flyway.setDataSource(config.get("db.url"), config.get("db.username"), config.get("db.password"));

        // Start the migration
        flyway.migrate();
    }
}

package hu.rbr.sfinapp;

import org.flywaydb.core.Flyway;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.sql.DataSource;

public class FlywayRunner {

    private final Logger log = LoggerFactory.getLogger(getClass());

    private final DataSource dataSource;

    @Inject
    public FlywayRunner(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public void run() {
        log.info("Starting flyway.");

        // Create the Flyway instance
        Flyway flyway = new Flyway();

        // Point it to the database
        flyway.setDataSource(dataSource);

        // Start the migration
        flyway.migrate();
    }
}

Fix Flyway datasource init