2017-11-28 1 views
1

저지 주석을 사용하여 REST 리소스를 작성했습니다. 이클립스에서 응용 프로그램을 실행할 때REST 애플리케이션은 Eclipse에서 실행되지만 실행 가능한 JAR로는 실행되지 않습니다. NoClassDefFoundError : javax/xml/bind/annotation/XmlElement

@Configuration 
@ApplicationPath("/api") 
public class JerseyConfiguration extends ResourceConfig { 
    public JerseyConfiguration() { } 

    @PostConstruct 
    public void setUp() { 
     register(AdminController.class); 
     register(AdminResource.class); 
     register(GenericExceptionMapper.class); 
    } 
} 

이 잘 작동 : 봄 부팅에서 그 일을하려면 내가 JerseyConfiguration 클래스를 추가했다. jar 파일을 만들고 실행할 때 다음과 같은 오류가 발생합니다.

12:45:15.311 [main] ERROR o.s.boot.SpringApplication : Application startup failed org.springframework.context.ApplicationContextException: Unable to start embedded container; 
nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Bean instantiation via constructor failed; 
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration$$EnhancerBySpringCGLIB$$d46b8aee]: Constructor threw exception; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceConfigCustomizer' defined in class path resource [org/springframework/boot/autoconfigure/jersey/JerseyAutoCon figuration$JacksonResourceConfigCustomizer.class]: Bean instantiation via factory method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jersey.ResourceConfigCustomizer]: Factory method 'resourceConfigCustomizer' threw exception; 
nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlElement 

아무도 왜 이러한 일이 발생하는지 말할 수 있습니까? 지금까지 내가 알고있는 javax/xml/bind/annotation 내가 자바 8 SDK를 사용하여 항아리를 시작 생각, 자바 8

답변

2

나는 봄 부팅 1.5.9.RELEASE을 사용하고있는 자바 (8) rt.jar

의 일부이지만, 정말로 Java 9 JRE Java 8 SDK java.exe로 jar를 시작하면 문제가 나타나지 않습니다. Java 8 SDK로 jar를 시작하면 문제가 해결됩니다.

관련 문제