Java.Lang.Noclassdeffounderror: Org/Springframework/Core/Env/Configurableenvironment

java.lang.NoClassDefFoundError: org/springframework/core/env/ConfigurableEnvironment

Recommended Approach

  1. Go to Spring boot Initialzr site and select web stack as a dependency as shown in below figure.
  2. As Spring Boot uses the concept of Opinionated dependencies and Bill of Materials, It will automatically pull the other dependencies and resolve your classNotFoundException issue. And in your case it misses out the Spring-core-4.2.4.RELEASE.jar dependency.
  3. Execute the Maven Goal as clean install spring-boot:run -e and you can find your maven dependencies in your IDE and below given is a sample POM 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.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>demo</name>
    <description>Demo 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-tomcat</artifactId>
    <scope>provided</scope>
    </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>

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

getting java.lang.NoClassDefFoundError: org/springframework/core/env/DefaultEnvironment

use this

  <constructor-arg type="java.lang.String" value="Zara"/>

Type definition is required when you use String.

Spring Boot ClassNotFoundException org.springframework.core.metrics.ApplicationStartup

I was able to solve this by downgrading Spring Boot:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>

Guess it's just not compatible with 2.4.0 yet.

Specifically I also had to ensure that I used 2.3.3.RELEASE and not anything more recent due to other issues I ran across.

Spring class EnvironmentCapable

I think that need use version 3.1.0 - in package org.springframework.core-3.1.0.M2.jar this class presents.



Related Topics



Leave a reply



Submit