我正在尝试将 spring boot 应用程序的 war 文件部署到 azure 应用程序服务。它部署成功。但是当我打开网址时,我得到 p>
This appname.azurewebsites.net page can’t be found.
No web page was found for the web address:https://appname.azurewebsites.net/
.
我在 localhost:9001
中看到登录页面但我在 azure 中收到上面提到的 404 错误。我对Spring了解不多。我只是想部署该应用程序。是否有地方我应该指定加载 appname.azurewebsites.net 时应提供哪个页面?
它适用于 localhost
尽管。我做错了什么?
我只上传了war
文件。我没有做任何其他事情来托管 azure 的应用程序服务的 tomcat。我还应该做些什么才能使其在 Azure 上运行吗?
最佳答案
请按照以下步骤操作:
- 将 Spring Boot 应用程序打包为 JAR 文件。 (您可以在pom.xml中使用
<packaging>
元素) - 将 JAR 文件上传到 WebApp 的 D:\home\site\wwwroot
- 将 JAR 文件重命名为 app.jar
- 在同一位置创建 web.config 并添加以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\app.jar"">
</httpPlatform>
</system.webServer>
</configuration>
关于java - 在 azure 中找不到该网址的网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59858445/