spring boot thymeleaf 项目未在外部 tomcat 中作为战争运行

问题描述 投票:0回答:0

我在 spring boot thymeleaf 中开发项目,当我打包为 war 时,它打包一切都很好,但是当我在 tomcat 上运行它时它没有启动我的应用程序。

首先我在pom中添加了

<packaging>war</packaging>.
其次,我在主类中扩展了 sprinbootservletintilzer。

`@SpringBootApplication 公共类 MedleaperApplication 扩展了 SpringBootServletInitializer {

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

@Override 
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return
  application.sources(MedleaperApplication.class); // Replace DemoApplication
}`

我添加的第三个---

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

之后 mvn clean 和 mvn clean install 并在 tmocat webapp 文件夹中 depolyed war 并运行 startup.bat 命令来运行 tomcat,它启动了 tomcat 但没有执行我的应用程序

我想运行我的应用程序,我已经完成了我知道的所有步骤,所以请任何人帮助如何在 tomcat 中将 spring boot 项目部署为 war 或 jar。

spring-boot tomcat web-applications thymeleaf war
© www.soinside.com 2019 - 2024. All rights reserved.