You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maven仓库无Spring3/4版本?Gradle遗留项目构建报错求助

解决Spring 3.2.18.RELEASE构建依赖问题及Java升级方案

1. 修复org.springframework:spring依赖找不到的问题

Spring 3.x版本已不再提供org.springframework:spring这个聚合Jar包,它被拆分为多个独立功能模块。你需要移除这个无效依赖,替换为项目实际用到的Spring核心模块:

修改build.gradle的dependencies块:

dependencies {
    ...
    implementation 'org.springframework.ldap:spring-ldap-core:2.4.1'
    implementation "org.springframework:spring-web:${org_springframework_version}"
    implementation "org.springframework:spring-webmvc:${org_springframework_version}"
    // 移除无效的spring聚合依赖,添加实际需要的核心模块示例
    implementation "org.springframework:spring-core:${org_springframework_version}"
    implementation "org.springframework:spring-context:${org_springframework_version}"
    implementation "org.springframework:spring-beans:${org_springframework_version}"
    implementation "org.springframework:spring-expression:${org_springframework_version}"
    ...
}

注:根据项目实际使用的Spring功能,调整添加的模块,确保覆盖代码中用到的Spring API。

2. 升级JDK到Java 8(兼容Spring 3.2.18.RELEASE)

Spring 3.2.18.RELEASE作为Spring 3.x的最终版本,原生支持Java 8。只需在build.gradle中配置Java版本:

plugins {
    id 'java'
    id 'maven-publish'
    id 'war'
}

// 添加Java版本配置
java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

repositories {
    mavenLocal()
    maven {
        url = uri('https://repo.maven.apache.org/maven2/')
    }
}

// 其余配置保持不变

3. 验证Spring LDAP兼容性

当前依赖的spring-ldap-core:2.4.1适配Spring 5+,与Spring 3.2.x存在兼容性问题,建议降级到适配Spring 3.x的版本:

implementation 'org.springframework.ldap:spring-ldap-core:1.3.2.RELEASE'

内容的提问来源于stack exchange,提问作者Tameem Khan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 05:35:17