java - 在 azure 中找不到该网址的网页

标签 java spring azure spring-boot

我正在尝试将 spring boot 应用程序的 war 文件部署到 azure 应用程序服务。它部署成功。但是当我打开网址时,我得到

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 &quot;%HOME%\site\wwwroot\app.jar&quot;">
        </httpPlatform>
    </system.webServer>
</configuration>

关于java - 在 azure 中找不到该网址的网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59858445/

相关文章:

java - 使用 GSON 将 java.io.File 解析为 JSON

Spring MVC Autowired 组件中的 null

Azure 表 "DELETE"返回 "inputs is not valid"

azure - 无法删除azure中的公共(public)IP地址

java - 如何在 Scala 中为存在类型显式指定参数化类型?

java - JSONException : No value for error

spring - 如何使用 Thymeleaf 和 Spring Boot 创建动态链接?

azure - provider.azurerm 不支持资源类型 "azurerm_network_interface_security_group_association"

JavaFX:从运行时加载的模态获取数据

java - 如何使用 spring 或 struts 实现在多个屏幕之间导航的订单工作流程