Spring Boot:WebServerException:无法启动嵌入式Tomcat

iCurious:

我正在尝试运行Spring Boot应用程序,但出现异常。我已经尝试了许多答案,例如mvn dependency:purge-local-repository,然后运行mvn spring-boot:run,更新spring boot 2版本等,但是由于我遇到了异常,因此没有一个解决问题的方法。

2019-12-05 00:06:00.787  INFO 19840 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-12-05 00:06:00.791  WARN 19840 --- [           main] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack tr
ace of thread:
 [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
 [email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
 [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
 [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
 [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 [email protected]/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.793  WARN 19840 --- [           main] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [pool-1-thread-2] but has failed to stop it. This is very likely to create a memory leak. Stack tr
ace of thread:
 [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
 [email protected]/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
 [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
 [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1177)
 [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 [email protected]/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.795  WARN 19840 --- [           main] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak.
 Stack trace of thread:
 [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
 [email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
 [email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
 [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
 [email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
 [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 [email protected]/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.798  WARN 19840 --- [           main] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [HikariPool-1 connection adder] but has failed to stop it. This is very likely to create a memory
leak. Stack trace of thread:
 [email protected]/java.net.SocketInputStream.socketRead0(Native Method)
 [email protected]/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
 [email protected]/java.net.SocketInputStream.read(SocketInputStream.java:168)
 [email protected]/java.net.SocketInputStream.read(SocketInputStream.java:140)
 [email protected]/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
 [email protected]/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:68)
 [email protected]/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1104)
 [email protected]/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:823)
 org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:140)
 org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:109)
 org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:67)
 org.postgresql.core.PGStream.receiveChar(PGStream.java:306)
 org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:405)
 org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:94)
 org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
 org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
 org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
 org.postgresql.Driver.makeConnection(Driver.java:454)
 org.postgresql.Driver.connect(Driver.java:256)
 com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:119)
 com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369)
 com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198)
 com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467)
 com.zaxxer.hikari.pool.HikariPool.access$100(HikariPool.java:71)
 com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:706)
 com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:692)
 [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:264)
 [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 [email protected]/java.lang.Thread.run(Thread.java:834)
2019-12-05 00:06:00.804  WARN 19840 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web serve
r; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-12-05 00:06:00.805  INFO 19840 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'application'
2019-12-05 00:06:00.806  INFO 19840 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'security'
2019-12-05 00:06:00.807  INFO 19840 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2019-12-05 00:06:02.244  INFO 19840 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2019-12-05 00:06:02.261  INFO 19840 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-12-05 00:06:02.276 ERROR 19840 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
        at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:542) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:124) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:178) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        ... 14 common frames omitted
Caused by: java.lang.IllegalArgumentException: Servlet must not be null
        at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.1.8.RELEASE.jar:5.1.8.RELEASE]
        at org.springframework.boot.web.servlet.ServletRegistrationBean.getDescription(ServletRegistrationBean.java:171) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.servlet.RegistrationBean.onStartup(RegistrationBean.java:48) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:227) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5132) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[na:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:456) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:105) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
        ... 19 common frames omitted

[WARNING]
java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
    at java.lang.Thread.run (Thread.java:834)
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh (ServletWebServerApplicationContext.java:155)
    at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:742)
    at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:389)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:311)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1213)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1202)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
    at java.lang.Thread.run (Thread.java:834)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize (TomcatWebServer.java:124)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init> (TomcatWebServer.java:86)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer (TomcatServletWebServerFactory.java:414)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer (TomcatServletWebServerFactory.java:178)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer (ServletWebServerApplicationContext.java:179)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh (ServletWebServerApplicationContext.java:152)
    at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:742)
    at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:389)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:311)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1213)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1202)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
    at java.lang.Thread.run (Thread.java:834)
Caused by: java.lang.IllegalArgumentException: Servlet must not be null
    at org.springframework.util.Assert.notNull (Assert.java:198)
    at org.springframework.boot.web.servlet.ServletRegistrationBean.getDescription (ServletRegistrationBean.java:171)
    at org.springframework.boot.web.servlet.RegistrationBean.onStartup (RegistrationBean.java:48)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize (ServletWebServerApplicationContext.java:227)
    at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup (TomcatStarter.java:53)
    at org.apache.catalina.core.StandardContext.startInternal (StandardContext.java:5132)
    at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1374)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute (InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal (ContainerBase.java:909)
    at org.apache.catalina.core.StandardHost.startInternal (StandardHost.java:841)
    at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1384)
    at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1374)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute (InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit (AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal (ContainerBase.java:909)
    at org.apache.catalina.core.StandardEngine.startInternal (StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal (StandardService.java:421)
    at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal (StandardServer.java:932)
    at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:183)
    at org.apache.catalina.startup.Tomcat.start (Tomcat.java:456)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize (TomcatWebServer.java:105)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init> (TomcatWebServer.java:86)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer (TomcatServletWebServerFactory.java:414)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer (TomcatServletWebServerFactory.java:178)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer (ServletWebServerApplicationContext.java:179)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh (ServletWebServerApplicationContext.java:152)
    at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:543)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:742)
    at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:389)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:311)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1213)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1202)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:542)
    at java.lang.Thread.run (Thread.java:834)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  37.901 s
[INFO] Finished at: 2019-12-05T00:06:03+05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:run (default-cli) on project sample-project: An exception occurred while running. null: InvocationTargetException: Unable to start web server; nested exception is org.
springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat: Servlet must not be null -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

我主要的春季启动文件是

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@Configuration
@EnableAsync
public class SampleProject extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(SampleProject.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SampleProject.class);
    }
}

我正在使用JDK 11.0.5。我在使用JDK 8的Google App Engine上运行了该程序,运行正常,但是由于出现以下错误,异步调用无法正常工作。

发生意外错误(类型=内部服务器错误,状态= 500)。必须在Servlet上启用异步支持,并为异步请求处理中涉及的所有过滤器启用异步支持。这是通过Java代码使用Servlet API或通过在Web.xml中的Servlet和过滤器声明中添加“ true”来完成的。

经过研究,我发现 GAE上的JDK8不支持NIO,因此我现在正在尝试将其迁移到JDK11。我们将不胜感激。谢谢!

更新:我的Servlet配置文件

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ServletConfig {
    @Bean
    public ServletRegistrationBean servletRegistrationBean() throws Exception {
        ServletRegistrationBean registrationBean = new ServletRegistrationBean();
        registrationBean.setLoadOnStartup(1);
        registrationBean.setAsyncSupported(true);
        return registrationBean;
    }
}

删除可能有冲突的Servlet配置文件后,出现以下错误

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.<init>(UnwrappingRepositoryInvokerFactory.java:57)

The following method did not exist:

    org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

    jar:file:/C:/Users/icurious/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

    file:/C:/Users/icurious/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry

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

Process finished with exit code 1
iCurious:

删除ServletRegistrationBeanI 之后,我发现springfox-swagger版本2.9.2与JDK 11不兼容,所以我也删除了它。此外,我使用下面提到的(感谢Andy的提示spring-plugin-core终于成功了!

    <dependency>
        <groupId>org.springframework.plugin</groupId>
        <artifactId>spring-plugin-core</artifactId>
        <version>2.0.0.RELEASE</version>
    </dependency>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

用于Spring Boot的嵌入式Redis

Spring Boot嵌入式Tomcat依赖项在启动时引发异常

如何使用嵌入式Tomcat 8和Spring Boot将子域转换为路径

Spring Boot应用程序未启动嵌入式Tomcat

Spring Boot嵌入式tomcat日志

无法在不同的Spring Boot应用程序中的不同端口上启动2个嵌入式active-mq

修改Spring Boot嵌入式Tomcat提取路径

Spring Boot数据嵌入式Cassandra

Spring Boot嵌入式Tomcat性能

我们是否可以避免Spring Boot应用程序重新启动来刷新与其嵌入式tomcat容器关联的证书?

Spring Boot + GWT嵌入式配置

带有嵌入式init.d脚本的Spring Boot应用程序无法在重启时启动

在Spring Boot嵌入式Tomcat中配置maxKeepAliveRequests

将Spring Boot Weblfux与嵌入式Tomcat结合使用

Spring Boot服务器无法启动嵌入式Tomcat服务器

Spring Boot Jetty / tomcat嵌入式访问日志配置

将AOP包含在Spring Boot中(使用JavaConfig)会导致嵌入式Tomcat无法启动

Spring Boot /安全性-在嵌入式Tomcat上运行时无法自定义安全性

Spring框架无法启动嵌入式容器

对Tomcat Boot的Spring Boot RestController的REST调用在Tomcat中产生404,但在嵌入式Tomcat中工作

与 SpringBootTest 一起使用时,Spring Boot 嵌入式 Tomcat 无法启动

Spring Boot 1.4.1 嵌入式 tomcat 8 - 日志缓冲 30 秒

Netbeans 8.2:如何在 osx 上的 Spring.Boot 项目中停止嵌入式 Tomcat?

无法使用嵌入式 Tomcat 浏览到 Spring Boot 应用程序

带有嵌入式 tomcat 的 Spring Boot 在端口上运行,但无法正常工作

Spring Boot,无法初始化嵌入式tomcat

spring-boot 嵌入式 tomcat 无法启动 [2.2.6 vs 2.2.2]

无法启动 bean 'webServerStartStop';无法启动嵌入式 Tomcat 服务器 - spring-boot-starter-web

Spring Boot 的嵌入式 Tomcat 忽略访问日志配置