經過一次SpringBoot打成war包部署到tomcat啓動總結通常jar包衝突的解決方法

啓動時,報錯信息以下:java

28-Sep-2018 16:55:41.567 嚴重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error during ServletContainerInitializer processing
 javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:158)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5311)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:974)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.springframework.util.ReflectionUtils.accessibleConstructor(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:155)
        ... 12 more

這個錯誤找了好久的緣由,通常都是jar包衝突致使,總結一下通常狀況下jar衝突的解決方案:
#####方案一:給JVM的啓動的時候添加「-XX:+TraceClassLoading」,通常能夠再tomcat後者eclipse(其餘IDE也能夠)中直接添加便可打印(經過該方法本次解決了幾個日誌包相互衝突的問題) #####方案二:再Eclipse中(其餘IDE本身查)按「Ctrl+Shift+T」實現根據類型打開,看是否有多個以下圖本次打開發現: #####方案三:再Eclipse中(其餘IDE本身查)中打開pom文件中的「Dependency Hierarchy」標籤逐個查找對應的錯誤,以下圖所示: 最終,本次發現「jcapytcha-all」jar包中引用了spring2.0而後致使項目中有兩個spring的反射工具類在外置tomcat部署啓動報錯,作個記錄,轉載註明出處!web

相關文章
相關標籤/搜索