springboot 启动报错 java.lang.IllegalStateException: Failed to introspect annotated methods on class org

idea启动springboot +maven项目报错:


   
   
  1. . ____ _ __ _ _
  2. /\\ / ___ '_ __ _ _(_)_ __ __ _ \ \ \ \
  3. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  4. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  5. ' |____| .__|_| |_|_| |_\__, | / / / /
  6. =========|_|==============|___/=/_/_/_/
  7. :: Spring Boot :: (v1.4.1.RELEASE)
  8. [ INFO ] [2017-11-03 14:50:17:017] com.taikang.Application [48] [main]- Starting Application on WMM with PID 4384 (started by Administrator in G:\workspace-s\IdeaProjects\hello)
  9. [ INFO ] [2017-11-03 14:50:17:017] com.taikang.Application [665] [main]- The following profiles are active: DEV
  10. [ INFO ] [2017-11-03 14:50:17:017] org.hibernate.validator.internal.util.Version [30] [background-preinit]- HV000001: Hibernate Validator 5.2.4.Final
  11. [ INFO ] [2017-11-03 14:50:18:018] org.springframework.context.annotation.AnnotationConfigApplicationContext [581] [main]- Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@bdd8f7: startup date [Fri Nov 03 14:50:18 CST 2017]; root of context hierarchy
  12. [ WARN ] [2017-11-03 14:50:18:018] org.springframework.context.annotation.AnnotationConfigApplicationContext [549] [main]- Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.taikang.Application]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
  13. Disconnected from the target VM, address: ' 127.0.0.1: 60450 ', transport: 'socket '
  14. [ ERROR] [2017-11-03 14:50:18:018] org.springframework.boot.SpringApplication [839] [main]- Application startup failed
  15. org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.taikang.Application]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
  16. at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:187)
  17. at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:324)
  18. at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:246)
  19. at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
  20. at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
  21. at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
  22. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523)
  23. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
  24. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
  25. at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
  26. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
  27. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
  28. at com.taikang.Application.main(Application.java:36)
  29. Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
  30. at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163)
  31. at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:301)
  32. at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:237)
  33. at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:204)
  34. at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173)
  35. ... 12 common frames omitted
  36. Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
  37. at java.lang.Class.getDeclaredMethods0(Native Method)
  38. at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
  39. at java.lang.Class.getDeclaredMethods(Class.java:1860)
  40. at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152)
  41. ... 16 common frames omitted
  42. Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
  43. at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  44. at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  45. at java.security.AccessController.doPrivileged(Native Method)
  46. at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  47. at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  48. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  49. at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  50. ... 20 common frames omitted
  51. Process finished with exit code 1

解决办法:

点此参考地址打开连接:https://stackoverflow.com/questions/37938289/spring-boot-java-lang-classnotfoundexception-javax-servlet-servletcontext-and


pom.xml中的

In maven, I changed the scope like this: <scope>provided</scope> to <scope>compile</scope> and it worked!!. 




In maven, I changed the scope like this: <scope>provided</scope> to <scope>compile</scope> and it worked!!. 
原文地址:https://blog.csdn.net/qq_32198005/article/details/78435648

猜你喜欢

转载自www.cnblogs.com/jpfss/p/11089078.html