天天看点

springboot打war包抛出org.springframework.context.ApplicationContextException: Unable to start web server

当我加入打war包的依赖后,在运行项目抛出以下异常

springboot打war包抛出org.springframework.context.ApplicationContextException: Unable to start web server

然后我在pom.xml文件中加了一个依赖解决了这个问题

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
           

打war包的依赖

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!-- 移除内置tomcat -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

           

加入依赖后在运行异常解决了

springboot打war包抛出org.springframework.context.ApplicationContextException: Unable to start web server