gpt4 book ai didi

java - Spring Boot 应用程序无法在 Tomcat 服务器上启动

转载 作者:行者123 更新时间:2023-11-28 22:49:31 25 4
gpt4 key购买 nike

我正在尝试将 spring boot 应用程序作为 WAR 部署到 tomcat 服务器。我可以很好地构建 war 并将其部署到 tomcat 服务器。当我启动服务器时,尽管我的 spring 应用程序从未运行过。服务器启动正常。我已经完成了 Spring 所说的一切,

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file

我的项目有自己的自定义父 POM,由 2 个模块组成。

我已经阅读了其他几个类似的线程,据我所知,我已经正确设置了所有内容,但显然有问题。任何帮助将不胜感激。

谢谢!

父pom

<groupId>com.project</groupId>
<artifactId>TelematicsNotificationSystem</artifactId>
<name>TelematicsNotificationSystem</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<java.version>1.8</java.version>
<artifact-deployer.version>2.0.0-RELEASE</artifact-deployer.version>
<cxf.version>2.5.2</cxf.version>
<start-class>com.project.TNS.TelematicsNotificationSystem</start-class>
</properties>

<modules>
<module>TelematicsNotificationSystem-wsclient</module>
<module>TelematicsNotificationSystem-web</module>
</modules>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
<version>1.5.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<version>1.5.0.RELEASE</version>
</dependency>

<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.6</version>
</dependency>

<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>1.3.0.RELEASE</version>
</dependency>
</dependencies>

Web 项目 Pom

<artifactId>TelematicsNotificationSystem-Web</artifactId>
<name>TelematicsNotificationSystem-Web</name>
<packaging>war</packaging>


<parent>
<groupId>com.project</groupId>
<artifactId>TelematicsNotificationSystem</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<properties>
<start-class>com.project.TNS.TelematicsNotificationSystem</start-class>
</properties>



<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>

我的应用类

package TNS;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

@SpringBootApplication
public class TelematicsNotificationSystem extends SpringBootServletInitializer{

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

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

最佳答案

请记住在 Tomcat 中部署后刷新应用程序。它可能运行良好,只需要刷新。

关于java - Spring Boot 应用程序无法在 Tomcat 服务器上启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44935831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com