首页 > 解决方案 > java.io.FileNotFoundException:类路径资源:AbstractCouchbaseDataConfiguration.class] 无法打开,因为它不存在

问题描述

我在我的 spring 批处理代码中将我的 couchbase 客户端版本从 2.3.4 升级到 3.2.1,所以我不得不将我的 spring-couchbase-data 版本也从 2 升级到 4。我遇到了以下错误,即使有不再引用此类。

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/data/couchbase/config/AbstractCouchbaseDataConfiguration.class] cannot be opened because it does not exist

我有 2 个项目,一个 CouchbaseIntegration(用于连接到 couchbase 并从中获取数据)和主项目 ApplicationDataExtractor。ApplicationDataExtractor 使用从 CouchbaseIntegration 构建的 jar。

来自 CouchbaseIntegration 的 build.gradle:

apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.8
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    compile group: 'commons-configuration', name: 'commons-configuration', version: '1.9'
    compile 'org.springframework.boot:spring-boot-starter-parent:2.5.6'
    
    compile("org.springframework.boot:spring-boot-maven-plugin:2.5.6")
    
    compile 'com.couchbase.client:java-client:3.2.1'
    compile 'org.json:json:20210307'
    compile group: 'org.springframework.data', name: 'spring-data-couchbase', version: '4.2.6'  
    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
    compile group: 'javax.transaction', name: 'jta', version: '1.1'
    compile group: 'org.jasypt', name: 'jasypt', version: '1.9.2'
    compile 'org.slf4j:jcl-over-slf4j:1.7.12'
    compile 'ch.qos.logback:logback-classic:1.1.3'
    
    testCompile group: 'junit', name: 'junit', version: '4.+'
    testCompile group: 'org.springframework', name: 'spring-test', version: '4.2.6.RELEASE'
}

test {
    systemProperties 'property': 'value'
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

task copyRuntimeLibs(type: Copy) {

    into "lib"

    from configurations.runtime

}

来自 ApplicationDataExtractor 的 build.gradle:

buildscript {
    repositories {
        maven { url "http://jcenter.bintray.com"}
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'war'

sourceCompatibility = 1.8
targetCompatibility = 1.8

version = '1.5'
war {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version
    }
    archiveName 'ApplicationDataExtractor.war'
}

repositories {
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-maven-plugin
    compile("org.springframework.boot:spring-boot-maven-plugin:2.5.6")
    compile("org.springframework.security:spring-security-crypto:");
    compile("org.bouncycastle:bcpg-jdk15on:1.55");
    compile("org.bouncycastle:bcprov-jdk15on:1.52");
    compile("org.springframework.security:spring-security-web:");
    compile("org.springframework.security:spring-security-config:");
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.hsqldb:hsqldb:")
    compile("org.springframework.boot:spring-boot-starter-web:") {
        //exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
    }
    compile("org.jasypt:jasypt:1.9.0")
    compile("org.springframework.boot:spring-boot-starter-batch:")
    compile("org.springframework:spring-oxm:")
    compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1")
    compile files('jdbclibs/ojdbc7.jar')
    compile files('jdbclibs/ucp.jar')
    compile files('jdbclibs/bcprov-jdk15on-155.jar')
    compile files('jdbclibs/CouchbaseIntegration-1.04.jar')
    compile ('org.springframework.data:spring-data-couchbase:4.2.6')
    compile ('com.couchbase.client:java-client:3.2.1')
    compile 'org.springframework.boot:spring-boot-starter-parent:2.5.6'
    
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    compile group: 'commons-configuration', name: 'commons-configuration', version: '1.9'
    compile group: 'org.jasypt', name: 'jasypt', version: '1.9.2'
    compile 'org.slf4j:jcl-over-slf4j:1.7.12'
    testCompile group: 'junit', name: 'junit', version: '4.+'

}

test {
    systemProperties 'property': 'value'
}

task copyRuntimeLibs(type: Copy) {

    into "lib"

    from configurations.runtime

}

springBoot {
  mainClass = "com.fico.om.apm.batch.ApplicationDataExtractorBoot"
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

标签: springspring-bootbuild.gradlespring-batchspring-data-couchbase

解决方案


推荐阅读