0

我正在尝试在 tomcat 服务器上部署 Spring Boot 应用程序,但收到错误为 SEVERE [http-nio-8080-exec-5] org.apache.catalina.startup.HostConfig.deployWAR 部署 Web 应用程序存档时出错

这是POM文件

<project xmlns="http://maven.apache.org/POM/4.0.0"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">

<modelVersion>4.0.0</modelVersion>
<groupId>com.springboot</groupId>
<artifactId>spring-boot-web-application-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
    <java.version>1.8</java.version>
    <start-class>com.springboot.MainApp</start-class>
</properties>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.2.1.Final</version>
    </dependency>

    <!-- JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) -->
    <!--<dependency>-->
    <!--<groupId>org.hibernate.javax.persistence</groupId>-->
    <!--<artifactId>hibernate-core</artifactId>-->
    <!--<version>1.0.1.Final</version>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <!--        <exclusions>
                    <exclusion>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <groupId>org.hibernate</groupId>
                    </exclusion>
                </exclusions>  -->
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <!-- Use MySQL Connector-J -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.185</version>
        <!-- $NO-MVN-MAN-VER$ -->
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.3.0.Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.3.0.Final</version>
    </dependency>


    <!-- JSTL tag lib -->
    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>javax.servlet.jsp.jstl-api</artifactId>
        <version>1.2.1</version>
    </dependency>

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>

    <!-- Tomcat for JSP rendering -->
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <!--<scope>provided</scope>-->
    </dependency>


    <!--<dependency>-->
        <!--<groupId>org.springframework.boot</groupId>-->
        <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
        <!--<scope>provided</scope>-->
    <!--</dependency>-->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.7</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>jquery</artifactId>
        <version>3.1.1</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
<packaging>war</packaging>

4

3 回答 3

2

使用https://start.spring.io/创建您的初始 POM / Spring Boot 应用程序。

您可以稍后根据需要添加依赖项。

于 2018-06-21T12:20:36.663 回答
0

我认为,您正在尝试在本地运行您的应用程序。Spring Boot 应用程序具有内置的 tomcat 服务器。为了在 Eclipse 中运行您的应用程序,1) 右键单击​​您的项目 --> 2) 转到 Run as --> 3) Java 应用程序 您的应用程序将启动。

在您的 pom 中添加 devTools 的依赖项,这样如果您对代码进行任何更改,服务器将自动重新启动。

于 2019-10-07T09:46:28.850 回答
-1

您不需要在 tomcat 中部署 spring-boot 项目,spring-boot 拥有自己的服务器来运行应用程序。因此,当您在服务器上部署应用程序时,我们可以借助 maven 构建和运行 spring-boot 应用程序。这是在 linux 中运行构建和运行应用程序的命令。

nohup mvn clean spring-boot:run

如果要重新启动服务器,则需要终止端口 ID

lsof -i : appPortNumber 

kill -9 processIdOfPort
于 2018-06-21T12:13:00.480 回答