Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

For a classic Spring Framework 4 application, declare the Context module directly in Maven:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>4.0.9.RELEASE</version>
</dependency>

4.0.9.RELEASE is the version shown in the historical Spring Framework 4.0 documentation, not a claim that it is the newest or best 4.x patch. Use the version required by your existing application and verify it in your repository. Spring 4 is a legacy compatibility choice in 2026; new applications should normally evaluate a currently supported Spring branch.

What org.springframework:spring-context means

org.springframework:spring-context is a Maven coordinate for Spring Framework’s application-context module. It supplies higher-level container features such as application contexts, bean creation, component scanning, configuration classes, and dependency-injection infrastructure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

It is not an all-in-one Spring JAR. Spring is deliberately modular. The framework’s artifact guide describes relationships among modules such as spring-context, spring-beans, and spring-core (Spring Framework artifact guide).

The conceptual module graph

spring-context
├── spring-aop
├── spring-beans
├── spring-core
└── spring-expression

The exact graph depends on the selected Spring version and any exclusions, so inspect Maven’s resolved graph instead of copying this list into your POM.

Read the Maven coordinates

Element Meaning Spring value
groupId Organization or project namespace org.springframework
artifactId Specific library or module spring-context
version Exact release Maven resolves For example, 4.0.9.RELEASE
scope When the dependency is available Usually Maven’s default compile
type Packaging type Defaults to jar

Put the declaration inside the project’s <dependencies> element. A standalone project normally needs an explicit version; a parent POM or imported BOM can supply one centrally.

Minimal Spring 4 Maven declaration

<project>
    <modelVersion>4.0.0</modelVersion>
    <!-- groupId, artifactId, version and Java compiler settings -->
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.0.9.RELEASE</version>
        </dependency>
    </dependencies>
</project>

Spring’s Framework 4 reference uses this coordinate and explains that normal released artifacts can be obtained from Maven Central (Spring Framework 4 overview). Replace the example version when your application’s compatibility policy specifies another 4.x release, and confirm that release exists in the repository your build actually uses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why Maven downloads other Spring JARs

When you request spring-context, Maven reads its POM, follows its declared dependencies, and resolves the resulting graph. These are transitive dependencies. You generally should not add every downloaded Spring JAR manually.

mvn dependency:tree -Dincludes=org.springframework

A direct dependency is still appropriate when your source code uses that module’s API. Declaring spring-context directly communicates that your application depends on application-context behavior rather than accidentally relying on another library’s transitive dependency.

Keep Spring modules on one compatible version

Explicit versions

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.0.9.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.0.9.RELEASE</version>
    </dependency>
</dependencies>

This works, but repeating versions becomes error-prone as modules grow.

Import the Spring Framework BOM

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>4.0.9.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
</dependencies>

<dependencyManagement> controls versions; it does not add a library. Each module you actually use must still be declared under <dependencies>. Maven documents this distinction at its POM reference. Spring’s Framework 4 guide recommends the BOM for aligned module versions.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the correct scope

Default compile scope

Use the default scope when application code imports Spring classes such as:

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

These APIs are needed while compiling, so omitting <scope> (or specifying compile) is correct.

Runtime scope

Spring’s documentation describes runtime for a deliberate case where code does not compile against Spring APIs and Spring is needed only during execution. It is not a universal optimization. provided is appropriate only when the deployment container genuinely supplies the library; test is wrong for production code.

A small application-context example

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        ApplicationContext context =
            new AnnotationConfigApplicationContext(AppConfig.class);
        MyService service = context.getBean(MyService.class);
        service.run();
    }
}
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("com.example")
public class AppConfig {
}

Because this source imports Context APIs, spring-context is a direct compile-time dependency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify what Maven resolved

  1. Run mvn clean dependency:tree -Dincludes=org.springframework.
  2. Confirm that spring-context has the intended version.
  3. Check that other Spring modules are not selected at incompatible versions.
  4. Use mvn dependency:tree -Dverbose to see omitted conflict paths.
  5. Run mvn help:effective-pom to inspect inherited and managed versions.
  6. Run mvn dependency:analyze to identify unused or undeclared usage.

Maven’s dependency mechanism, mediation rules, exclusions, and analysis goals are documented at the Maven dependency guide.

Troubleshoot common failures

“Could not resolve artifact”

  • Check spelling of groupId, artifactId, and version.
  • Verify that the selected release exists in the configured repository.
  • Check proxy, mirror, credentials, network, and offline settings.
  • Retry with mvn -U clean package; this refreshes release and snapshot checks but cannot repair an invalid coordinate.
  • Inspect whether a corporate mirror or local cache contains an incomplete download.

Multiple Spring versions or linkage errors

Errors such as NoSuchMethodError, ClassNotFoundException, NoClassDefFoundError, LinkageError, and some BeanDefinitionStoreException failures can indicate version skew. Run:

mvn dependency:tree -Dincludes=org.springframework

Align modules with explicit versions, the Spring BOM, or the dependency-management system supplied by Spring Boot. Avoid arbitrary exclusions: removing a transitive artifact can turn a version conflict into a missing-class failure.

Maven Central versus Spring repositories

Normal Spring GA releases generally come from Maven Central. Spring’s Framework 4 documentation describes separate repositories for milestones and snapshots; add those only when intentionally consuming a pre-release or an artifact unavailable from your configured repository.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Old Spring 4 on a newer JDK

Historical Spring 4 documentation records a Java SE 6-era baseline (upgrade notes). That does not guarantee trouble-free operation on every modern JDK. Test the complete application stack, including compiler and Maven plugins, servlet or Java EE APIs, third-party libraries, reflective-access behavior, and the javax.* versus jakarta.* ecosystem.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Special case: Spring Boot

Do not automatically add a manually versioned Spring Framework 4 dependency to a Spring Boot project. Boot normally manages a coordinated Spring and third-party dependency set. An independent override can create incompatibilities with Boot, logging, or integrations.

Inspect mvn dependency:tree and the Boot parent or BOM first. If an override is unavoidable, choose it according to Boot’s dependency-management rules rather than selecting a Spring version in isolation.

Is Spring Framework 4 still appropriate?

Use Spring 4 when maintaining a legacy application with a controlled runtime, existing libraries tied to the javax.* ecosystem, or an upgrade whose scope is not yet manageable. Keep a maintenance, security, and testing plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a new application, or when you need current security fixes, supported JDKs, or Jakarta EE integrations, evaluate a currently supported Spring branch. The Spring Framework version guidance is published at the official version policy page. The Maven Central listing retrieved for this topic showed a much newer spring-context release, 7.0.8; check the repository and support policy at the time you choose a version (Maven Central artifact page).

Which additional module do you need?

spring-context covers the application context, not every Spring feature. Spring MVC typically requires spring-web and spring-webmvc; transactions, JDBC, ORM, messaging, validation, and other features have their own modules. Add the direct modules your code uses and let Maven resolve their transitive requirements.

Frequently Asked Questions

Do I need to add spring-core and spring-beans separately?

Usually no. spring-context declares the required relationships, so Maven resolves them transitively. Add a module directly only when your application intentionally uses its API.

Can I omit the version?

Only when a parent POM or imported BOM supplies dependency management. A standalone Maven project normally needs an explicit version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I find which dependency brought in an older Spring JAR?

Run mvn dependency:tree -Dverbose -Dincludes=org.springframework and inspect the path leading to the older artifact.

Is spring-context enough for Spring MVC?

Not generally. MVC applications usually also need spring-web and spring-webmvc, plus whatever web runtime and application features they use.

Can Spring 4 run on my JDK?

Its historical documentation targeted Java 6 or newer, but that is not a modern compatibility guarantee. Test the entire application and dependency stack on the specific JDK you plan to deploy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.