복붙노트

[SPRING] java.lang.NoClassDefFoundError : org / springframework / core / env / ConfigurableEnvironment

SPRING

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

Spring Boot를 사용하여 간단한 RESTful 서비스를 작성하려고합니다. 그러나 해결할 수없는 오류 메시지가 있습니다. 나는 연구를 해왔고 SpringBoot 버전간에 충돌이있는 것 같았지만 어떻게 제거 할 수 있을지 확신하지 못했습니다.

나는이 Spring Boot App을 가지고있다 :

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * REST Service application
 */
@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

이 pom.xml과 관련 :

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.websystique.springmvc</groupId>
    <artifactId>Spring4MVCHelloWorldRestServiceDemo</artifactId>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <name>Spring4MVCHelloWorldRestServiceDemo Maven Webapp</name>

    <properties>
        <springframework.version>4.3.0.RELEASE</springframework.version>
        <jackson.library>2.7.5</jackson.library>
        <spring.batch.version>2.1.9.RELEASE</spring.batch.version>
    </properties>

    <dependencies>

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

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version> <!-- Or whatever JUnit you're using. -->
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.library}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>${jackson.library}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-core</artifactId>
            <version>${spring.batch.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


    </dependencies>


    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <warName>Spring4MVCHelloWorldRestServiceDemo</warName>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <finalName>Spring4MVCHelloWorldRestServiceDemo</finalName>
    </build>
</project>

나를 위해 괜찮아 보이지만이 오류가 발생합니다.

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/env/ConfigurableEnvironment
    at com.application.Application.main(Application.java:13)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.env.ConfigurableEnvironment
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

해결법

  1. ==============================

    1.권장 접근법

    권장 접근법

  2. ==============================

    2.봄 부팅이 실행 중입니다 -

    봄 부팅이 실행 중입니다 -

    <spring.version>4.3.2.RELEASE</spring.version>
    

    를 위해 -

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

    가져 오는 동안 -

        <springframework.version>4.3.0.RELEASE</springframework.version>
    

    당신은 마스터 pom에서 확인할 수 있습니다 -

    https://github.com/spring-projects/spring-boot/blob/v1.4.0.RELEASE/spring-boot-dependencies/pom.xml

    봄 버전을 업데이트 할 수 있습니까? 또는 Maven 종속성을 관리하는 방법

  3. ==============================

    3.저장소에서 springframework 폴더를 삭제 한 다음 Alt + F5를 눌러 프로젝트를 업데이트하십시오 (업데이트 스냅 샷 적용).

    저장소에서 springframework 폴더를 삭제 한 다음 Alt + F5를 눌러 프로젝트를 업데이트하십시오 (업데이트 스냅 샷 적용).

    C:\Users\xxxx\.m2\repository\org\springframework
    
  4. ==============================

    4.runnig 버전 2.0.0을 1.4.0으로 변경 한 boot-startter-parent 구성을 변경하여 Java 응용 프로그램을 실행할 수 있었고이 오류를 제거했습니다.

    runnig 버전 2.0.0을 1.4.0으로 변경 한 boot-startter-parent 구성을 변경하여 Java 응용 프로그램을 실행할 수 있었고이 오류를 제거했습니다.

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>  <!-- changed it to version 1.4.0 from 2.0.0-->
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    
  5. ==============================

    5.boot-startter-parent 버전을 1.5.1.RELEASE에서 1.4.0.RELEASE로 변경했습니다.

    boot-startter-parent 버전을 1.5.1.RELEASE에서 1.4.0.RELEASE로 변경했습니다.

  6. ==============================

    6.

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
      </parent>
    
  7. from https://stackoverflow.com/questions/39245732/java-lang-noclassdeffounderror-org-springframework-core-env-configurableenviron by cc-by-sa and MIT license