복붙노트

[SPRING] java.lang.ClassNotFoundException : org.springframework.core.ResolvableTypeProvider [복제]

SPRING

java.lang.ClassNotFoundException : org.springframework.core.ResolvableTypeProvider [복제]

나는 Spring annotated scheduler program을 작성했지만, 실행하면 게시판에 오류 메시지가 나타납니다.

SchedulerConfig.java

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import com.fwd.pmap.scheduler.SchedulerApp;

@Configuration
@EnableScheduling
public class SchedulerConfig implements SchedulingConfigurer {

    @Bean
    public SchedulerApp bean() {
        return new SchedulerApp();
    }

    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setScheduler(taskExecutor());
    }

    @Bean(destroyMethod="shutdown")
    public Executor taskExecutor() {
        return Executors.newScheduledThreadPool(4);
    }
}

SchedulerApp.java

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.fwd.pmap.memberInterfaceFile.CsvReader;
import com.fwd.pmap.memberInterfaceFile.CsvWriter;;

@Component
public class SchedulerApp
{
    @Scheduled(cron="0 0 17 * ? *")
    public void importInterfaceFile()
    {
        CsvReader reader = new CsvReader();
        try {
            reader.importInterfaceFile();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Scheduled(cron="0 0 6 * ? *")
    public void generateInterfaceFile()
    {
        CsvWriter writer = new CsvWriter();
        try {
            writer.generateInterfaceFile();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

그리고 메인 클래스는 스케줄러 작업을 시작합니다.

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;

public class SchedulerMain
{
    @SuppressWarnings({ "unused", "resource" })
    public static void main(String[] args) {
        AbstractApplicationContext context = new AnnotationConfigApplicationContext(SchedulerConfig.class);
    }
}

내가 가진 오류 메시지는 다음과 같습니다.

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/ResolvableTypeProvider
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    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)
    at com.fwd.pmap.scheduler.SchedulerMain.main(SchedulerMain.java:10)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.ResolvableTypeProvider
    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)
    ... 13 more

Pom.hml

<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.fwd</groupId>
  <artifactId>fwd-PMAP</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <jboss.version>3.0.2.Final-redhat-15</jboss.version>
    <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
    <maven-war-plugin.version>2.6</maven-war-plugin.version>

    <!-- Spring -->
    <spring-framework.version>4.0.3.RELEASE</spring-framework.version>

    <!-- Hibernate / JPA -->
    <hibernate.version>4.2.21.Final</hibernate.version>

    <!-- Logging -->
    <logback.version>1.1.7</logback.version>

    <!-- Restlet -->
    <restlet.version>2.3.4</restlet.version>
    <commons-lang.version>3.4</commons-lang.version>
    <jackson.version>2.7.1</jackson.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.jboss.spec</groupId>
      <artifactId>jboss-javaee-6.0</artifactId>
      <version>${jboss.version}</version>
      <type>pom</type>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
          <groupId>org.jboss.spec.javax.ws.rs</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Spring ORM support -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>${spring-framework.version}</version>
    </dependency>

    <!-- Spring Scheduler -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
      <version>1.3.3.RELEASE</version>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${logback.version}</version>
    </dependency>

    <!-- Hibernate -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>${hibernate.version}</version>
    </dependency>

    <!-- Super CSV -->
    <dependency>
      <groupId>net.sf.supercsv</groupId>
      <artifactId>super-csv</artifactId>
      <version>2.4.0</version>
    </dependency>

    <!-- Excel Writer -->
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.9</version>
    </dependency>

    <!-- Copy POJO to POJO -->
    <dependency>
      <groupId>org.modelmapper</groupId>
      <artifactId>modelmapper</artifactId>
      <version>0.7.5</version>
    </dependency>

    <!-- Restlet -->
    <dependency>
      <groupId>org.restlet.jee</groupId>
      <artifactId>org.restlet.ext.servlet</artifactId>
      <version>${restlet.version}</version>
    </dependency>

    <dependency>
      <groupId>org.restlet.jse</groupId>
      <artifactId>org.restlet.ext.json</artifactId>
      <version>${restlet.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${commons-lang.version}</version>
    </dependency>

    <!-- JSON -->
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.json</artifactId>
        <version>1.0.4</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
    </dependency>

  </dependencies>

  <build>
    <finalName>${project.artifactId}</finalName>

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

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>${maven-war-plugin.version}</version>
          <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
          <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
            <failOnMissingWebXml>false</failOnMissingWebXml>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

최근 2 개월 전에 코드를 다시 살펴본 후 깨진 것으로 밝혀 질 때까지 2 개월 전부터 정상적으로 작동했습니다. 누구든지 포인터를 줄 수 있습니까?

해결법

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

    1.프로젝트 디렉토리로 cd하십시오.

    프로젝트 디렉토리로 cd하십시오.

    용도:

    mvn dependency:tree
    

    lib jar의 충돌 버전이 있는지 확인하십시오.

  2. from https://stackoverflow.com/questions/38135633/java-lang-classnotfoundexception-org-springframework-core-resolvabletypeprovide by cc-by-sa and MIT license