java - 使用azure运行java应用程序但访问不工作

标签 java azure spring-boot

我刚刚开始使用 azure 平台,我有一个问题。

我将应用程序上传到 azure 并运行它,但当我尝试访问它时,它不起作用,但返回 404 not found

也许我做错了什么?

这是我连接的存储库:

https://github.com/idanovadia/ServerAlgoSearchImplementation_v2

例如,当我在本地主机上运行它时: http://localhost:8080/getMaze/prim

现在我尝试了: https://searchnow.azurewebsites.net/getMaze/prim

here is the screen from azure

enter image description here

最佳答案

我看到您尝试将java应用程序打包到jar文件中,并在web应用程序中使用web.config运行该jar文件。这是运行 Spring Boot 应用程序的旧方法。

其实有一个通用的、更好的方法。只是将你的spring boot应用程序打包成war包。然后您可以使用 tomcat 容器将其部署到 Azure Web 应用程序。

1。初始化Spring Boot项目时需要选择打包为war:

enter image description here

2。设置打包文件名为ROOT.war

打开pom.xml,添加以下行:

enter image description here

如果你运行mvn clean package,你会得到一个ROOT.war文件

3。使用 Tomcat 创建 Web 应用程序

enter image description here

4。在Web应用程序的\site\wwwroot\webapps文件夹下部署ROOT.war

enter image description here

5。重新启动您的网络应用程序。

enter image description here

关于java - 使用azure运行java应用程序但访问不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58076120/

相关文章:

java - CompletableFuture 未在超时时完成

java - 如何对字节数组集合进行 Collections.binarySearch ?

java - 读取 p 值的 .csv 文件,如何忽略/转换某些输入?

c# - Microsoft Visual C++ 2010 SP1 可在 Azure 上重新分发吗?

java - 如何为复合主键创建 JPA 类

java - 我的自定义 Activity 中的谷歌地图

sql - 将 Excel 从 Azure Blob 存储导入到 Sql Server 时出现数据截断问题

bash - 如何执行存储在 Github 中的 SQL 文件?

java - Spring boot创建bean时出错

java - 从java中的列表中获取一行而不是三行?