Spring boot: Unable to start embedded Tomcat servlet container

后端 未结 8 1406
孤街浪徒
孤街浪徒 2020-12-09 15:26

I\'m new to Spring Boot and having with error while running my application. I\'m following a tutorial and I believe I\'m having proper parent and dependencies with POM, plea

相关标签:
8条回答
  • 2020-12-09 16:06

    In my condition when I got an exception " Unable to start embedded Tomcat servlet container",

    I opened the debug mode of spring boot by adding debug=true in the application.properties,

    and then rerun the code ,and it told me that java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String

    Thus, we know that probably I'm using a servlet API of lower version, and it conflicts with spring boot version.

    I went to my pom.xml, and found one of my dependencies is using servlet2.5, and I excluded it.

    Now it works. Hope it helps.

    0 讨论(0)
  • 2020-12-09 16:07

    Simple way to handle this is to include this in your application.properties or .yml file: server.port=0 for application.properties and server.port: 0 for application.yml files. Of course need to be aware these may change depending on the springboot version you are using. These will allow your machine to dynamically allocate any free port available for use. To statically assign a port change the above to server.port = someportnumber. If running unix based OS you may want to check for zombie activities on the port in question and if possible kill it using fuser -k {theport}/tcp. Your .yml or .properties should look like this. server: port: 8089 servlet: context-path: /somecontextpath

    0 讨论(0)
提交回复
热议问题