我正在开发一个大型项目,我必须加载内部依赖项,但是获取无法加载配置类的异常。我已经使用带有@ComponentScan(basePackages = {"com.xyz"})
注释的基本包名称但是应用程序无法加载上下文。以下是ExceptionInterceptorAutoConfiguration类,它已作为项目中的maven依赖项导入。
@Configuration
public class ExceptionInterceptorAutoConfiguration {
public ExceptionInterceptorAutoConfiguration() {
}
@Bean
@ConditionalOnMissingBean({DefaultExceptionInterceptor.class})
public DefaultExceptionInterceptor defaultExceptionInterceptor() {
return new DefaultExceptionInterceptor() {
};
}
@Bean
@ConditionalOnClass({HystrixRuntimeException.class, HystrixExceptionInterceptor.class})
public HystrixExceptionInterceptor hystrixRuntimeExceptionInterceptor() {
return new HystrixExceptionInterceptor() {
};
}
@Bean
@ConditionalOnClass({ServiceExceptionV2Interceptor.class})
public ServiceExceptionV2Interceptor serviceExceptionV2Interceptor() {
return new ServiceExceptionV2Interceptor() {
};
}
@Bean
@ConditionalOnClass({FacadeExceptionV2Interceptor.class})
public FacadeExceptionV2Interceptor facadeExceptionV2Interceptor() {
return new FacadeExceptionV2Interceptor() {
};
}
@Bean
@ConditionalOnClass({ServiceExceptionInterceptor.class})
public ServiceExceptionInterceptor serviceExceptionInterceptor() {
return new ServiceExceptionInterceptor() {
};
}
@Bean
@ConditionalOnClass({FacadeExceptionInterceptor.class})
public FacadeExceptionInterceptor facadeExceptionInterceptor() {
return new FacadeExceptionInterceptor() {
};
}
@Bean
@ConditionalOnClass({MethodArgumentNotValidExceptionInterceptor.class})
public MethodArgumentNotValidExceptionInterceptor methodArgumentNotValidExceptionInterceptor() {
return new MethodArgumentNotValidExceptionInterceptor() {
};
}
@Bean
@ConditionalOnClass({MethodArgumentTypeMismatchExceptionInterceptor.class})
public MethodArgumentTypeMismatchExceptionInterceptor methodArgumentTypeMismatchExceptionInterceptor() {
return new MethodArgumentTypeMismatchExceptionInterceptor() {
};
}
@Bean
@ConditionalOnClass({ServletRequestBindingExceptionInterceptor.class})
public ServletRequestBindingExceptionInterceptor servletRequestBindingExceptionInterceptor() {
return new ServletRequestBindingExceptionInterceptor() {
};
}
}
以下是我在这方面获得任何帮助的例外情况。
java.lang.IllegalStateException: Cannot load configuration class: com.xyz.commons.sdk.logging.autoconfigure.ExceptionInterceptorAutoConfiguration
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:403) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:249) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:283) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:127) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at com.xyz.consumer.dispute.Application.main(Application.java:19) [classes/:na]
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724) ~[na:1.8.0_121]
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531) ~[na:1.8.0_121]
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355) ~[na:1.8.0_121]
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286) ~[na:1.8.0_121]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) ~[na:1.8.0_121]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) ~[na:1.8.0_121]
at java.lang.reflect.Executable.declaredAnnotations(Executable.java:599) ~[na:1.8.0_121]
at java.lang.reflect.Executable.declaredAnnotations(Executable.java:597) ~[na:1.8.0_121]
at java.lang.reflect.Executable.getAnnotation(Executable.java:570) ~[na:1.8.0_121]
at java.lang.reflect.Method.getAnnotation(Method.java:622) ~[na:1.8.0_121]
at java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:258) ~[na:1.8.0_121]
at java.lang.reflect.AccessibleObject.isAnnotationPresent(AccessibleObject.java:191) ~[na:1.8.0_121]
at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:617) ~[spring-core-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.annotation.BeanAnnotationHelper.isBeanAnnotated(BeanAnnotationHelper.java:33) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.isMatch(ConfigurationClassEnhancer.java:420) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
答案 0 :(得分:1)
我之前遇到过类似的问题,我在source / java下创建了资源选项卡,但它失败了。你能检查一下吗?