Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot access org.springframework.context.ConfigurableApplicationContext class file

I am new to spring boot, while trying to build my first spring boot project (Maven) in intellij using spring initializer, I am getting this error when I run my project after creating it:

cannot access org.springframework.context.ConfigurableApplicationContext class file for org.springframework.context.ConfigurableApplicationContext not found

I followed many tutorials but every time I am getting this error, how to resolve this?

My pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.boot</groupId>
    <artifactId>das-boot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>First spring boot app</name>
    <description>project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>    
like image 492
I.shL Avatar asked Aug 09 '16 15:08

I.shL


3 Answers

I was able to fix it by the following steps:

  1. File -> Invalidate Cache and Restart
  2. File -> New -> Project from existing source
  3. Select the pom.xml file just (not the whole project directory) to load the project. Project will be setup automatically.
like image 63
Bilal Ahmed Yaseen Avatar answered Nov 15 '22 17:11

Bilal Ahmed Yaseen


I am using IntelliJ and gradle for my spring boot application and encountered the same issue.

I resolved it by deleting the auto-generated .iml file under classpath.

Hope it helps anyone who comes after.

like image 34
Dan Lee Avatar answered Nov 15 '22 16:11

Dan Lee


For me ,first answer only works when open the child project as a new project in a new window .

You can try delete main.iml or xxx.iml in your child project src\main\main.iml. That works for me

EDIT: dont worry, main.iml is auto generated by idea

like image 28
Evol Rof Avatar answered Nov 15 '22 15:11

Evol Rof