0

I was trying to run a legacy project using spring version 3 with build.gradle:

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

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

ext {
    org_springframework_version = '3.2.18.RELEASE'
}

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}"
    implementation "org.springframework:spring:${org_springframework_version}"
...
}
...

but getting the following error when trying to build:

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find org.springframework:spring:3.2.18.RELEASE.
     Searched in the following locations:
       - file:/C:/Users/.../.m2/repository/org/springframework/spring/3.2.18.RELEASE/spring-3.2.18.RELEASE.pom
       - https://repo.maven.apache.org/maven2/org/springframework/spring/3.2.18.RELEASE/spring-3.2.18.RELEASE.pom
     Required by:
         project :

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

I checked https://repo.maven.apache.org/maven2/org/springframework/spring/ and it looks like there is no spring 3 or 4 in the repo.

I cannot use any newer spring version as there are tons of other dependencies and legacy code in the project that should be kept as is.

I am confused as to why is this the case or how to build my project now. Any help is appreciated.

PS. A little background: I have a legacy project that relies on really old tech (Stripes framework) which is straight up refusing to work with spring 5+. It is running on Java 6 now. I want to upgrade it to java 8. But spring 2.x dependency is not letting me to.

4
  • Any particular reason for not using mavenCentral() repository?
    – 1615903
    Commented Nov 21, 2022 at 6:05
  • Using repositories { mavenLocal() mavenCentral() } produces same issue nonetheless. Am i doing something wrong? Commented Nov 21, 2022 at 6:09
  • 2
    The full spring jar hasn't been available for quite some time. So yes there is no and has never been a 3 and 4 release of spring.jar nor is there now as it only contains the pom.xml. So remove the spring dependency and replace with things like spring-context-support depending on your needs. Also use mavenCentral() instead of a hardcoded URL in your repo.
    – M. Deinum
    Commented Nov 21, 2022 at 6:16
  • As I stated before the full spring jar is not available anymore since Spring 2.5. It isn't anymore and will never be anymore, as stated include the individual modules from Spring you need.
    – M. Deinum
    Commented Nov 29, 2022 at 8:37

1 Answer 1

3

The fullblown spring.jar hasn't been available since Spring Framework 3.0.0. Spring 2.5.6 is the last one that has the full Spring jar. Since then only the smaller modules have been available.

The versions for 5.x you see are only some top level pom.xml files which, I assume, have been published accidentally (as for 6.x they aren't there anymore).

In short remove the following line from your dependencies

implementation "org.springframework:spring:${org_springframework_version}"

So it doesn't try to resolve something that hasn't been available since Spring 2.5.6 anymore. What you should include are the dependencies for the modules you need (something like the below dependencies).

implementation "org.springframework:spring-web:${org_springframework_version}"
implementation "org.springframework:spring-webmvc:${org_springframework_version}"
implementation "org.springframework:spring-jdbc:${org_springframework_version}"
implementation "org.springframework:spring-orm:${org_springframework_version}"
implementation "org.springframework:spring-oxm:${org_springframework_version}"

As an additional note replace

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

with

mavenCentral()

This will allow Gradle to pick a better suited mirror of Maven for your environment.

10
  • What if I want to use spring 3.x or 4.x? I have a legacy project that relies on really old tech (Stripes framework) which is straight up refusing to work with spring 5+. It is running on Java 6 now. I want to upgrade it to java 8. But spring 2.x dependency is not letting me to. Commented Nov 29, 2022 at 8:32
  • Where do I stsate you cannot use Spring 3 or 4? I state you need to include the indivudual modules and remove the all encompassing dependency as that simply doesn't exists anymore!.
    – M. Deinum
    Commented Nov 29, 2022 at 8:37
  • 1
    Third time remove the all encompassing dependency... I explicitly state that you need to remove that dependency in my answer and you keep shoving it in there.
    – M. Deinum
    Commented Nov 29, 2022 at 8:49
  • 1
    Exactly... Figure out which modules you need and include those. Included that in the answer.
    – M. Deinum
    Commented Nov 29, 2022 at 8:53
  • 2
    The spring dependency hasn't been renamed to spring-core. spring-core is only a small subset of what was in the spring module (which included everything but web related stuff).
    – M. Deinum
    Commented Nov 29, 2022 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.