Spring интеграция RedisLockRegistry с Spring-контекстом

Мы решили использовать RedisLockRegistry, добавив spring-integration в мой проект, разработанный с помощью Spring boot 1.5.7.

Но когда мы добавляем в проект spring-integration-starter и spring-integration-redis, кварц выдает ошибку.

Если я изменю spring-context на spring-context-support или добавлю spring-context-support, это не будет ошибкой.

Почему я должен добавить поддержку spring-context вместо spring-context или изменить ее?

градиент

buildscript {
    ext {
        springBootVersion = '1.5.7.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

allprojects {
    repositories {
        mavenCentral()

        mavenLocal()
    }

    apply plugin: 'java'
    apply plugin: 'org.springframework.boot'
    apply plugin: "io.spring.dependency-management"
    apply plugin: 'maven'
    apply plugin: 'idea'

    sourceCompatibility = 1.8

    idea {
        module {
            sourceDirs += file('build/classes/main/generated')
            generatedSourceDirs += file('build/classes/main/generated')
        }
    }

    dependencies {
        compileOnly 'org.projectlombok:lombok'

        testCompile 'org.springframework.boot:spring-boot-starter-test'
        testCompile 'com.h2database:h2'
        testCompile 'org.springframework.security:spring-security-test'
    }
}

group = 'com.example.redislock'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}
compileJava.dependsOn(processResources)


dependencies {
    compile 'org.springframework.boot:spring-boot-starter-aop'
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.boot:spring-boot-starter-integration'

    compile 'org.quartz-scheduler:quartz:2.3.0'
    compile 'org.springframework:spring-core'
    //compile 'org.springframework:spring-context'

    compile 'org.springframework:spring-context-support'

    compile 'org.springframework.integration:spring-integration-redis'


    compile 'org.hibernate:hibernate-java8'
    compile 'io.springfox:springfox-swagger2:2.6.1'
    compile 'io.springfox:springfox-swagger-ui:2.6.1'
    compile 'org.springframework.boot:spring-boot-starter-actuator'
    compile 'org.flywaydb:flyway-core:4.2.0'

    compileOnly 'org.springframework.boot:spring-boot-configuration-processor'

    runtime 'org.postgresql:postgresql:42.2.1'
}

Это ошибка, дающая класс:

package com.example.redislock.DemoRedisLockGradle.scheduler;

import org.quartz.Job;
import org.quartz.JobDetail;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
import org.springframework.scheduling.quartz.JobDetailFactoryBean;

@Configuration
public class ExampleScheduler {

    @Bean(name = "asdTrigger")
    public CronTriggerFactoryBean triggerFactoryBean(@Qualifier("asdJobFactory") JobDetailFactoryBean jobFactory) {
        return createTriggerFactoryBean(jobFactory.getObject());
    }

    @Bean(name = "asdJobFactory")
    public JobDetailFactoryBean asd() {
        return createJobDetailFactoryBean(ExampleJob.class);
    }

    CronTriggerFactoryBean createTriggerFactoryBean(JobDetail jobDetail) {
        CronTriggerFactoryBean ctFactory = new CronTriggerFactoryBean();
        ctFactory.setName("Example Factory");
        ctFactory.setCronExpression("0 0/1 * * * ?");
        ctFactory.setJobDetail(jobDetail);
        return ctFactory;
    }

    JobDetailFactoryBean createJobDetailFactoryBean(Class<? extends Job> jobClass) {
        JobDetailFactoryBean factory = new JobDetailFactoryBean();
        factory.setJobClass(jobClass);
        return factory;
    }
}

Он не может найти кварц.CronTriggerFactoryBean и кварц.JobDetailFactoryBean

заранее спасибо


person Rhmn61    schedule 27.07.2018    source источник


Ответы (1)


Я нашел решение. Если я исключаю spring-data-redis на spring-integration-redis, добавлять поддержку spring-context-support не нужно.

compile('org.springframework.boot:spring-boot-starter-integration')
compile('org.springframework.integration:spring-integration-redis') {
    exclude group: 'org.springframework.data', module: 'spring-data-redis'
}
person Rhmn61    schedule 27.07.2018