【发布时间】:2019-06-10 06:54:34
【问题描述】:
我正在尝试将 war Spring Boot 项目部署到 Tomcat 服务器中,该服务器将其他项目绑定到某些端口。当我部署新的war 项目时,服务似乎没有绑定到从Spring Boot application-properties 分配的端口8082。
首先,我在server.xml上添加了新的端口8082
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="-1"
redirectPort="8443" /> //That was already specified
<Connector port="8082" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" /> //My addition
然后netstat -plnt我看到端口可用
tcp6 0 0 :::8082 :::* LISTEN -
通过转到/opt/apache-tomcat-7.0.88/webapps,似乎我的新war 应用程序已部署。
应用程序日志没有显示任何错误或异常,并且 Spring Boot 应用程序似乎正在运行。以下是 Spring 的完整日志:https://pastebin.com/nX04gjE3
当我尝试使用
测试服务时wget http://localhost:8082/services/test
我得到以下信息
--2019-06-10 09:49:56-- http://localhost:8082/services/test
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8082... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-06-10 09:49:56 ERROR 404: Not Found.
每次更改后,我当然会重新启动 apache。 这是一个部署的服务器,而不是在本地机器上,我所做的每一个更改都是用 putty 和 winscp 进行的。
ServicesApplication.java
@SpringBootApplication
public class ServicesApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ServicesApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(ServicesApplication.class, args);
}
}
application-properties
server.port=8082
http.port=8082
logging.file = /opt/logs/services.log
spring.datasource.url=jdbc:mysql://X.X.X.X/name?useSSL=false
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
编辑:我不需要在8082 上运行该应用程序我可以为其他人8080 接受相同端口的答案。
【问题讨论】:
-
API URL 可能有问题。检查基本 URL。 localhost:8082/services/test
-
本地工作
-
你的战争是怎么打的?是 services.war 吗?
-
是的,tomcat 似乎可以正确提取文件夹。
标签: java spring spring-boot tomcat