记一次ideal启动SpringBootServletInitializer异常的问题;

文章讲述了作者在将SpringBoot项目从jar包转换为war包后遇到启动错误,原因是`IllegalStateException:Failedtointrospectannotatedmethodsonclassorg.springframework.boot.web.servlet.support.SpringBootServletInitializer`。解决方法是在IntelliJIDEA中调整项目结构的依赖设置。
摘要由CSDN通过智能技术生成

springboot启动报错:nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer

问题:

  今天将一个springboot工程,由jar包形式改为war包,启动一直报错:nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer,详细内容如下

 

D:\software\Java\jdk1.8.0_121\bin\java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:55330,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=55329 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:C:\Users\zhangpengbo\.IntelliJIdea2017.3\system\captureAgent\debugger-agent.jar=C:\Users\zhangpengbo\AppData\Local\Temp\capture1.props -Dfile.encoding=UTF-8 -classpath "D:\software\Java\jdk1.8.0_121\jre\lib\charsets.jar;D:\software\Java\jdk1.8.0_121\jre\lib\deploy.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-32.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;D:\software\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;D:\software\Java\jdk1.8.0_121\jre\lib\javaws.jar;D:\software\Java\jdk1.8.0_121\jre\lib\jce.jar;D:\software\Java\jdk1.8.0_121\jre\lib\jfr.jar;D:\software\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;D:\software\Java\jdk1.8.0_121\jre\lib\jsse.jar;D:\software\Java\jdk1.8.0_121\jre\lib\management-agent.jar;D:\software\Java\jdk1.8.0_121\jre\lib\plugin.jar;D:\software\Java\jdk1.8.0_121\jre\lib\resources.jar;D:\software\Java\jdk1.8.0_121\jre\lib\rt.jar;E:\Git\study-nginx\target\classes;D:\jar\org\springframework\boot\spring-boot-starter-web\2.0.6.RELEASE\spring-boot-starter-web-2.0.6.RELEASE.jar;D:\jar\org\springframework\boot\spring-boot-starter\2.0.6.RELEASE\spring-boot-starter-2.0.6.RELEASE.jar;D:\jar\org\springframework\boot\spring-boot\2.0.6.RELEASE\spring-boot-2.0.6.RELEASE.jar;D:\jar\org\springframework\boot\spring-boot-autoconfigure\2.0.6.RELEASE\spring-boot-autoconfigure-2.0.6.RELEASE.jar;D:\jar\org\springframework\boot\spring-boot-starter-logging\2.0.6.RELEASE\spring-boot-starter-logging-2.0.6.RELEASE.jar;D:\jar\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\jar\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\jar\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;D:\jar\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;D:\jar\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\jar\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;D:\jar\org\springframework\boot\spring-boot-starter-json\2.0.6.RELEASE\spring-boot-starter-json-2.0.6.RELEASE.jar;D:\jar\com\fasterxml\jackson\core\jackson-databind\2.9.7\jackson-databind-2.9.7.jar;D:\jar\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;D:\jar\com\fasterxml\jackson\core\jackson-core\2.9.7\jackson-core-2.9.7.jar;D:\jar\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.7\jackson-datatype-jdk8-2.9.7.jar;D:\jar\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.7\jackson-datatype-jsr310-2.9.7.jar;D:\jar\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.7\jackson-module-parameter-names-2.9.7.jar;D:\jar\org\hibernate\validator\hibernate-validator\6.0.13.Final\hibernate-validator-6.0.13.Final.jar;D:\jar\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;D:\jar\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;D:\jar\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;D:\jar\org\springframework\spring-web\5.0.10.RELEASE\spring-web-5.0.10.RELEASE.jar;D:\jar\org\springframework\spring-beans\5.0.10.RELEASE\spring-beans-5.0.10.RELEASE.jar;D:\jar\org\springframework\spring-webmvc\5.0.10.RELEASE\spring-webmvc-5.0.10.RELEASE.jar;D:\jar\org\springframework\spring-aop\5.0.10.RELEASE\spring-aop-5.0.10.RELEASE.jar;D:\jar\org\springframework\spring-context\5.0.10.RELEASE\spring-context-5.0.10.RELEASE.jar;D:\jar\org\springframework\spring-expression\5.0.10.RELEASE\spring-expression-5.0.10.RELEASE.jar;D:\jar\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;D:\jar\org\springframework\spring-core\5.0.10.RELEASE\spring-core-5.0.10.RELEASE.jar;D:\jar\org\springframework\spring-jcl\5.0.10.RELEASE\spring-jcl-5.0.10.RELEASE.jar;D:\jar\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\software\IntelliJ IDEA 2017.3.4\lib\idea_rt.jar" com.study.nginx.NginxApplication
Connected to the target VM, address: '127.0.0.1:55330', transport: 'socket'

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.6.RELEASE)

2021-06-10 22:31:15.121  INFO 12128 --- [           main] com.study.nginx.NginxApplication         : Starting NginxApplication on LAPTOP-4FCSUVTB with PID 12128 (E:\Git\study-nginx\target\classes started by zhangpengbo in E:\Git\study-nginx)
2021-06-10 22:31:15.129  INFO 12128 --- [           main] com.study.nginx.NginxApplication         : No active profile set, falling back to default profiles: default
2021-06-10 22:31:15.185  INFO 12128 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@140f651: startup date [Thu Jun 10 22:31:15 CST 2021]; root of context hierarchy
2021-06-10 22:31:15.270  WARN 12128 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.study.nginx.NginxApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
2021-06-10 22:31:15.316 ERROR 12128 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.study.nginx.NginxApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:91) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:692) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:530) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]
    at com.study.nginx.NginxApplication.main(NginxApplication.java:23) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.servlet.support.SpringBootServletInitializer
    at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:169) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:393) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:318) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170) ~[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    ... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_121]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_121]
    at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_121]
    at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:158) ~[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]
    ... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
    ... 21 common frames omitted

Disconnected from the target VM, address: '127.0.0.1:55330', transport: 'socket'

Process finished with exit code 1

解决方法:

  打开idea,按照顺序找:File -> Project Strucyure -> Dependencies,选择tomcat核心依赖包,将Provided改为Compile,然后启动,就ok了

 亲测有效,不过在自己的电脑上面不需要修改,也不会进行报错。(具体原因还不太清楚,不知道是不是因为ideal,或者maven的版本问题导致)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值