sun.reflect.annotation.TypeNotPresentExceptionProxy

错误1:sun.reflect.annotation.TypeNotPresentExceptionProxy

网上搞得比较复杂,目的不是研究它就想要处理掉,所以就没做什么断点调试。

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-02 23:46:06.276 ERROR 6372 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) 

解决方案

启动类注解上加个排除声明就好了:(exclude = SecurityAutoConfiguration.class)

import org.activiti.spring.boot.SecurityAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class ActivitiAppliction {
    public static void main(String[] args) {
        SpringApplication.run(ActivitiAppliction.class, args);
    }
}

错误二:class path resource [processes/] cannot be resolved to URL because it does not exist


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-02 23:51:12.263 ERROR 13420 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositoryService' defined in class path resource [com/yan/activiti/config/ActivitiConfig.class]: Unsatisfied dependency expressed through method 'repositoryService' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processEngine' defined in class path resource [org/activiti/spring/boot/DataSourceProcessEngineAutoConfiguration$DataSourceProcessEngineConfiguration.class]: Unsatisfied dependency expressed through method 'processEngine' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springProcessEngineConfiguration' defined in class path resource [org/activiti/spring/boot/DataSourceProcessEngineAutoConfiguration$DataSourceProcessEngineConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.spring.SpringProcessEngineConfiguration]: Factory method 'springProcessEngineConfiguration' threw exception; nested exception is java.io.FileNotFoundException: class path resource [processes/] cannot be resolved to URL because it does not exist
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769) 

解决方案1(推荐):

yaml文件中设置启动时不检查已有的流程文件

spring:
  activiti:
    check-process-definitions: false 

解决方案2:

在resources目录下新建processes目录,并且目录下不能为空。随便放个文件就行了。

相比而言,方案1使用起来更方便,推荐1。


版权声明:本文为oPeiJie1原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。