Closed 1084077463 closed 8 months ago
该项目为非web项目,使用了spring-boot-starter,导致我在idea中maven打包,会默认打出一个spring-invoke-start的jar,启动项目的时候,也会加载该jar。导致项目启动时,一直报错要找EnableSpringMvcRequestMapping这个类,麻烦在加载时判断项目是否含有这个类在做后续的操作。最终通过debug才找到是加载了spring-invoke-start下面的spring.factories这个才引起的错误。 16:17:37.767 [main] ERROR o.s.b.SpringApplication - [reportFailure,818] - Application run failed java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext at com.hxl.plugin.scheduledinvokestarter.components.spring.controller.EnabledSpringMvcRequestMapping.canSupport(EnabledSpringMvcRequestMapping.java:17) at com.hxl.plugin.scheduledinvokestarter.components.ComponentLoader.run(ComponentLoader.java:58) at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:765) at org.springframework.boot.SpringApplication.lambda$callRunners$2(SpringApplication.java:749) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:744) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) at com.shsany.EdgeApplication.main(EdgeApplication.java:16)
很厉害,能定位到具体的jar,确实是这个引起的,没有测试过非web项目,这个我会优先兼容,可以在设置中禁用动态刷新技术。
已修复
该项目为非web项目,使用了spring-boot-starter,导致我在idea中maven打包,会默认打出一个spring-invoke-start的jar,启动项目的时候,也会加载该jar。导致项目启动时,一直报错要找EnableSpringMvcRequestMapping这个类,麻烦在加载时判断项目是否含有这个类在做后续的操作。最终通过debug才找到是加载了spring-invoke-start下面的spring.factories这个才引起的错误。 16:17:37.767 [main] ERROR o.s.b.SpringApplication - [reportFailure,818] - Application run failed java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext at com.hxl.plugin.scheduledinvokestarter.components.spring.controller.EnabledSpringMvcRequestMapping.canSupport(EnabledSpringMvcRequestMapping.java:17) at com.hxl.plugin.scheduledinvokestarter.components.ComponentLoader.run(ComponentLoader.java:58) at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:765) at org.springframework.boot.SpringApplication.lambda$callRunners$2(SpringApplication.java:749) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:744) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) at com.shsany.EdgeApplication.main(EdgeApplication.java:16)