스프링 부트 오류:java.lang.ArrayStoreException:sun.reflect.annotation.존재하지 않는 유형예외 프록시
응용 프로그램을 시작하기 위해 스프링 부트를 사용하고 싶은데 pom.xml에 관련 jar를 추가한 후 이 오류가 반환됩니다.또한 conflict jar가 원인일 수도 있습니다.
어플.자바
package com.mm.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@ComponentScan("com.mm.controller")
@Configuration
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
//spring properties xml
ApplicationContext context = new ClassPathXmlApplicationContext(
"Spring-Module.xml");
SpringApplication.run(Application.class, args);
}
@Bean
public InternalResourceViewResolver setupViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
return resolver;
}
}
오류:
Error starting ApplicationContext. To display the auto-configuration report enabled debug logging (start with --debug)
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
atorg.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:909)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:898)
at com.mm.application.Application.main(Application.java:20)
주요 문제:
Caused by: java.lang.ArrayStoreException:sun.reflect.annotation.TypeNotPresentExceptionProxy
atsun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:673)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480)
atsun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306)
atsun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:241)
atsun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88)
atsun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3178)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3185)
at java.lang.Class.getDeclaredAnnotations(Class.java:3166)
atorg.springframework.core.annotation.AnnotationUtils.isAnnotationDeclaredLocally(AnnotationUtils.java:395)
atorg.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:281)
atorg.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:265)
atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.isHandler(RequestMappingHandlerMapping.java:173)
atorg.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:123)
atorg.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:103)
atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:126)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 15 more
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<properties>
<start-class>com.kdubb.springboot.Application</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<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</groupId>
<artifactId>spring-dao</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
로그인 컨트롤러
package com.mm.controller;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@Component
public class LoginController {
@RequestMapping(value = "/CreditRating", method = RequestMethod.GET)
public String index(Model model) {
model.addAttribute("wisdom", "Goodbye XML");
// renders /WEB-INF/jsp/Login.jsp
return "Login";
}
@RequestMapping(value = "/CreditRating/GoLogin")
public String login(Model model) {
model.addAttribute("wisdom", "Goodbye XML");
// renders /WEB-INF/jsp/index.jsp
return "index";
}
}
솔루션은 실제 비호환성의 근본 원인에 따라 달라질 수 있습니다.이러한 문제를 조사하는 가장 좋은 방법은 다음과 같습니다.
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
중단점을 클래스 'Type Not Present'의 생성자에 넣습니다.Exception Proxy' (1개만 있습니다)
디버깅 모드에서 실행한 후에는 정확히 무엇이 잘못되었는지 확인하고 결과를 바탕으로 수행할 작업을 결정할 수 있습니다(의존관계 추가, autoconfig 제외 등).
구체적인 경우 브레이크 포인트에서 이를 알 수 있었습니다.
java.lang.ClassNotFoundException: org.springframework.integration.config.IntegrationManagementConfigurer
솔루션으로는 '통합'을 제외하기로 결정했습니다.자동 설정은 다음과 같습니다.
@SpringBootApplication(exclude = IntegrationAutoConfiguration.class)
Andy Wilkinson이 이 GitHub 문제 또는 이 스레드에서 설명한 바와 같이, 이러한 불명확한 예외는 일부 주석이 클래스 경로에 없는 클래스를 참조할 때 발생합니다.
이러한 종류의 문제는 최근 Spring Boot 버전에서는 대부분 수정되었지만 코드로부터 트리거할 수도 있습니다(예:@AutoConfigureAfter(X.class)
수업 장소X
클래스 패스에 없습니다.
spring-boot-starter-parent 2.0.0에서도 같은 문제가 있었습니다.M6.
해결 방법
제거하는 것이었다.
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
<version>3.1.11</version>
</dependency>
포함하다
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
대신.
다음과 같은 문제가 있었습니다.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
이전 투고와 같이 솔루션은 다음 항목만 추가하는 것이었습니다.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
저도 같은 예외가 있었습니다만, 제 spring-boot-starter-parent는 아래와 같이 버전 1.3.3이었습니다.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
1.4.1로 업그레이드할 때 예외가 표시됨
제 해결책은
나는 나쁜 의존관계를 끊어야 했다.
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
또한 Spring Boot 1.4.0 릴리즈 노트에 따라 아래의 의존관계로 대체하십시오.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
문제는 단순히 몇 가지 중요한 변경을 한 후 검증을 실행하기 전에 프로젝트를 청소하지 않았다는 것입니다.
이 에러에서도 같은 문제가 발생했습니다.
Error creating bean with name 'org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration': Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
POM.xml에서 다음 의존관계를 사용했더니 문제가 해결되었습니다.
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-spring-boot-autoconfigure -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-autoconfigure</artifactId>
<version>3.2.1</version>
</dependency>
추가 솔루션 접근법
spring-boot-boot-web-services
위의 답변에서 제시된 의존성은 양호하고 작동하지만 웹 컨텍스트를 올릴 필요가 없는 경우에는 과도합니다.내 말은, 만약 당신의 애플리케이션이 웹 어플리케이션이 되고 싶지 않다면.이 경우 적어도 저에게는 다음과 같은 얇은 의존관계를 추가하면 문제가 해결되었습니다.
org.springframework: spring-webmvc
implementation 'org.springframework:spring-webmvc:5.2.1.RELEASE'
spring JPA 를 사용하고 있는 경우는, 다음의 의존 관계가 pom.xml 에 추가되어 있는 것을 확인해 주세요.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Java 8에서 이전 버전의 Spring(1.x) 및 Websphere Liberty 22.0.0.3을 사용할 때 이 문제가 발생했습니다.최신 WLP(22.0.0.13)에서는 문제가 발생하지 않게 되었다.
언급URL : https://stackoverflow.com/questions/24352967/spring-boot-errorjava-lang-arraystoreexception-sun-reflect-annotation-typenotp
'your programing' 카테고리의 다른 글
유효한 JSON을 얻기 위한 정규식 이스케이프 (0) | 2023.03.13 |
---|---|
CMS를 직접 작성해야 합니까? (0) | 2023.03.13 |
angularjs 텍스트 영역 문자 카운터 (0) | 2023.03.13 |
WooCommerce 변수 제품의 리셋 변동 버튼을 제거합니다. (0) | 2023.03.13 |
Transofrm sql 쿼리를 사용하여 wordpress 쿼리를 새 wp_query로 실행합니다. (0) | 2023.03.13 |