Running Liquibase with CDI on Wildfly 8

2019-02-28 23:39发布

I am trying to run Liquibase scripts using CDI on WildFly 8.1.0.Final and I am getting this error:

Unsatisfied dependencies for type ResourceAccessor with qualifiers @LiquibaseType

My POM has these dependencies:

<dependencies>
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-core</artifactId>
        <version>3.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-cdi</artifactId>
        <version>3.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.mattbertolini</groupId>
        <artifactId>liquibase-slf4j</artifactId>
        <version>1.2.1</version>
    </dependency>
</dependencies>

My CDI Bean is as follows:

import javax.annotation.Resource;
import javax.enterprise.inject.Produces;
import javax.sql.DataSource;

import liquibase.integration.cdi.CDILiquibaseConfig;
import liquibase.integration.cdi.annotations.LiquibaseType;
import liquibase.resource.ClassLoaderResourceAccessor;
import liquibase.resource.ResourceAccessor;

public class LiquibaseStarter {
    @Produces
    @LiquibaseType
    public CDILiquibaseConfig createConfig() {
        CDILiquibaseConfig config = new CDILiquibaseConfig();
        config.setChangeLog("liquibase/parser/core/xml/simpleChangeLog.xml");
        return config;
    }

    @Resource(name="java:jboss/datasources/ExampleDS")
    private DataSource ds;

    @Produces
    @LiquibaseType
    public DataSource createDataSource() {
        return ds;
    }

    @Produces
    @LiquibaseType
    public ResourceAccessor create() {
        return new ClassLoaderResourceAccessor(getClass().getClassLoader());
    }
}

My project is a simple WAR. What am I doing wrong?

1条回答
Melony?
2楼-- · 2019-03-01 00:03

LiquibaseStarter has no bean-defining annotation. Add @Dependent at class-level.

查看更多
登录 后发表回答