1. 程式人生 > >【報錯記錄】記一次Springboot 打包jar後放在伺服器上執行失敗的排錯

【報錯記錄】記一次Springboot 打包jar後放在伺服器上執行失敗的排錯

使用mvn package -DSkipTests打包成jar包,然後上傳到伺服器。執行java -jar XXX.jar --env=pro後丟擲:

[localhost-startStop-1] ERROR o.s.boot.web.embedded.tomcat.TomcatStarter -[TomcatStarter.java:62]- Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'httpPutFormContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException
2018-11-07 14:33:08,931 [localhost-startStop-1] WARN  org.apache.catalina.loader.WebappClassLoaderBase -[DirectJDKLog.java:180]- The web application [ROOT] appears to have started a thread named [Druid-ConnectionPool-Create-1066241105] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
 com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2441)
2018-11-07 14:33:08,932 [localhost-startStop-1] WARN  org.apache.catalina.loader.WebappClassLoaderBase -[DirectJDKLog.java:180]- The web application [ROOT] appears to have started a thread named [Druid-ConnectionPool-Destroy-1066241105] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Thread.sleep(Native Method)
 com.alibaba.druid.pool.DruidDataSource$DestroyConnectionThread.run(DruidDataSource.java:2538)
2018-11-07 14:33:08,932 [localhost-startStop-1] WARN  org.apache.catalina.loader.WebappClassLoaderBase -[DirectJDKLog.java:180]- The web application [ROOT] appears to have started a thread named [lettuce-eventExecutorLoop-1-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
 io.netty.util.concurrent.SingleThreadEventExecutor.takeTask(SingleThreadEventExecutor.java:251)
 io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:64)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

一開始沒有仔細看maven打包情況,忽略了maven打包的提示資訊:

[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.boot:boot-security:jar:1.0
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.fasterxml.jackson.core:jackso
n-databind:jar -> version (?) vs 2.7.4 @ line 161, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]

最後發現問題是,maven有個依賴包重複添加了,且版本不一樣,去掉後就好了。