在Wildfly 8上使用CDI运行Liquibase

时间:2014-11-17 02:10:27

标签: cdi liquibase wildfly-8

我正在尝试使用WildFly 8.1.0.Final上的CDI运行Liquibase脚本,我收到此错误:

Unsatisfied dependencies for type ResourceAccessor with qualifiers @LiquibaseType

我的POM有这些依赖关系:

<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>

我的CDI Bean如下:

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());
    }
}

我的项目是一个简单的WAR。我做错了什么?

1 个答案:

答案 0 :(得分:7)

LiquibaseStarter没有bean定义注释。在班级添加@Dependent