The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files
Solution 1
Your Maven cache is corrupted on the second machine. The JAR can't be opened, that's why you get this exception.
You can fix that by running this command on the second machine for that project:
mvn dependency:purge-local-repository
If that doesn't work, try remove your local repo on that machine (~/.m2/repository/org/springframework
) and run mvn package
again.
Solution 2
I also faced the same issue before. Some dependency corruption might have occurred. You can purge and re-resolve the dependencies. For that :
- go to the project location where the pom.xml is present.
open a command prompt there and enter the command below :
mvn dependency:purge-local-repository -DreResolve=true
Solution 3
I had the same issue and I followed these steps to fix it:
1. Close Eclipse
2. Remove all files inside the repository folder .m2/repository
3. reopen Eclipse and update your Maven project
Solution 4
- Find out the version of spring-context your project uses:
(in Eclipse : Project Explorer -> [your project] -> Maven Dependencies)
or
mvn dependency:tree
Lists all dependencies for your project
- Delete the folder
org/springframework/spring-context/5.0.9.RELEASE
from your maven repository.m2/repository
. Assuming5.0.9.RELEASE
is the spring-context release version.
Solution 5
I had the same problem. I resolved this my deleting the local repository directory of Maven (.m2) on your local computer. It resolved the problem for me.
Admin
Updated on July 28, 2022Comments
-
Admin almost 2 years
I am following the tutorial at spring.io to build a spring app using spring boot.
I can get the program to run perfectly on one computer. When I try on a different computer I get the following error
The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files
I have tried deleting and adding my JRE Systems Library (JDK 1.8), as well as cleaning and updating the project using maven, and even deleting and re-importing the entire project. All of these methods have shown no success.
My pom file is
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.1.RELEASE</version> </parent> <groupId>test.api</groupId> <artifactId>api.test</artifactId> <version>0.0.1-SNAPSHOT</version> <name>api.test Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <properties> <java.version>1.8</java.version> </properties> <build> <finalName>api.test</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
The class that is giving me the error is the HelloWorldConfiguration.java class
package hello; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class HelloWorldConfiguration { public static void main(String[] args) { SpringApplication.run(HelloWorldConfiguration.class, args); } }
Any help would be greatly appreciated. Thank you.
-
Admin over 7 yearsI think I have a bigger issue hidden somewhere. I am now getting
Failed to instantiate SLF4J LoggerFactory
when I try to run the code. Thank you for your help though -
Jan Dolejsi over 4 yearsA repeatable solution is preferable. There should be a way of ensuring the environment and the dependencies listed in the pom result in the same behavior.
-
Admin over 2 yearsAs it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.