从maven

时间:2017-01-05 22:48:14

标签: java spring maven spring-boot liquibase

我正在尝试在应用程序上执行liquibase rollback命令

我有我的变更集:

<changeSet id="dmsTestSQL" author="ahmed" 
        dbms="mysql">
        <sqlFile path="db/changelog/sql/add.sql"
             encoding="UTF-8"
             splitStatements="true"
             stripComments="true"/>
        <rollback>
            <sqlFile path="db/changelog/sql/rollback.sql"/>
        </rollback>
    </changeSet>

我有我的配置类:

@Configuration
public class LiquibaseConfiguration {

    @Value("${com.autogravity.dms.liquibase.changelog}")
    private String changelog;

    @Value("${spring.datasource.url}")
    private String url;

    @Value("${spring.datasource.username}")
    private String username;

    @Value("${spring.datasource.password}")
    private String password;

    /*@Value("${liquibase.rollback-file}")
    private String rollback;*/

    @Bean
    public SpringLiquibase liquibase()  {
        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setDataSource(dataSource());
        liquibase.setChangeLog(changelog);
        //liquibase.setRollbackFile(new File(rollback));
        return liquibase;
    }

    public MysqlDataSource dataSource() {
        MysqlDataSource ds=new MysqlDataSource();
        ds.setURL(url);
        ds.setUser(username);
        ds.setPassword(password);
        ds.setAutoReconnect(true);
        ds.setCreateDatabaseIfNotExist(true);
        return ds;
    }

}

我也在我的pom文件中创建了mvn插件:

<plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>2.0.2</version>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <configuration>
                        <tag>${project.version}</tag>
                        <dropFirst>false</dropFirst>
                        <changeLogFile>classpath:/db/changelog/db.changelog.xml</changeLogFile>
                        <driver>com.mysql.jdbc.Driver</driver>
                        <url>jdbc:mysql://localhost:3306/db</url>
                        <username>root</username>
                        <password>test</password>
                    </configuration>
                    <goals>
                        <goal>rollback</goal>
                        <goal>tag</goal>
                    </goals>
                </execution>
            </executions>
        </plugin> 

我尝试运行命令liquibase:rollback -Dliquibase.rollbackTag=1.0,但后来我收到错误:

Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.2:rollback (default-cli) on project dealer-microservice: The driver has not been specified either as a parameter or in a properties file. -> [Help 1]

我不理解之前的错误,我试图搜索但却一无所获。我可以帮助解释这个错误

0 个答案:

没有答案