如何在Tomcat上部署Spring Boot WAR文件?

huangapple go评论61阅读模式
英文:

how to deploy the spring boot war on tomcat?

问题

我正在尝试在VS Code中使用以下命令创建Spring Boot应用程序的WAR文件:

mvn clean
mvn clean install
mvn clean install
mvn package

当我部署WAR文件到Tomcat并在浏览器中访问以下URL时:http://localhost:8080/welcome,Tomcat已启动,但我的欢迎路由不起作用,它给了我以下错误:

pom.xml:

application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/cghs2test

当我部署WAR文件到Tomcat时,我的控制器没有被触发。
这是我的控制器:

英文:

I am trying to make the war file of the spring boot application in vs code using this command
mvn clean
mvn clean install
or
mvn clean install
or
mvn package

when i am deploying the war on tomcat and check into the browser and hit this url http://localhost:8080/welcome but tomcat started and my welcome routes not working it gives me the error

pom.xml:

application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/cghs2test

when i deploying the war on tomcat my controller not hit
this is my controller

答案1

得分: 0

以下是已经翻译好的部分:

为构建Tomcat WAR文件:
Tomcat 9.x - Spring Boot 2.x
Tomcat依赖
pom.xml
Spring Boot Starter Data JPA
Spring Boot Starter Web
Spring Boot Starter Tomcat
Tomcat Embed Core
Thymeleaf(可选)

英文:

for building the tomcat war:
tomcat9.x - spring boot 2.x
dependecy tomcat
pom.xml
spring-boot-starter-data-jpa
spring-boot-starter-web
spring-boot-starter-tomcat
tomcat-embed-core
thymleaf(opt)

huangapple
  • 本文由 发表于 2023年7月10日 15:11:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76651442.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定