![](/img/trans.png)
[英]Spring Boot App works on local Tomcat but not on remote server
[英]Spring boot standalone runs well on local but cannot be accessed on remote server
我在春季启动时实现了一个hello world。
我正在使用嵌入式tomcat,这是在application.properties中的设置。
server.contextPath=/test
server.port=8080
我可以通过[localhost:8080/test/index.html]
毫无问题地访问它。
但是,将jar文件上传到Digital Ocean上的ubuntu 14.04并正常启动后,我无法通过[machine-ipaddress:8080/test/index.html]
访问该文件。 它给我一个404错误。
我可以看到应用程序正在监听端口。
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 4284/java
我检查了iptable设置,没有任何阻塞。
我也尝试停止此操作,并在远程服务器上运行常规的空tomcat,访问[machine-ipaddress:8080]
没问题。
任何想法都欢迎。
找到了问题。 原因是我使用maven webapp原型创建了一个空项目,将index.html放在webapp下并将其打包为jar 。
奇怪的是,我可以使用java -jar test.jar在本地运行它。
将index.html移到resources / static后,它可以在远程服务器上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.