gpt4 book ai didi

java - 无法将 Spring Boot 应用程序部署到 Azure

转载 作者:搜寻专家 更新时间:2023-11-01 01:50:26 26 4
gpt4 key购买 nike

我无法让我的 Spring Boot 站点在 Azure Web 实例上做出响应。我已经关注了Java app instructionsupload instructions 。看起来 IIS 服务器正在接收请求,但 war 中的 servlet 没有响应。根据文档,有一些问题。特别是,web.config 应部署到 wwwroot 并指定 java 路径以及转发端口。我相信我已经涵盖了这些基础知识——我的 web.config 粘贴在下面。

我确实尝试从市场部署 Tomcat 服务器,效果很好。当我替换我的 war 文件和 web.config 时,spring boot 应用程序无法工作。

一条有趣的信息是 HTTP_PLATFORM_PORT 环境变量似乎没有定义。

应用程序设置:

app settings

Azure 控制台信息(环境变量和 Web.config):

D:\home\site\wwwroot

> dir
D:\home\site\wwwroot
Volume in drive D is Windows
Volume Serial Number is 789E-197B

Directory of D:\home\site\wwwroot

03/01/2016 02:14 AM <DIR> .
03/01/2016 02:14 AM <DIR> ..
02/29/2016 08:15 PM <DIR> bin
03/01/2016 01:49 AM 8,771,899 web-0.0.1-SNAPSHOT.war
03/01/2016 02:10 AM 496 web.config
03/01/2016 02:08 AM 496 web.custom.config
03/01/2016 01:54 AM 4,868 web.tomcat.config
03/01/2016 02:14 AM <DIR> webapps



> echo %java_home%
D:\home\site\wwwroot
D:\Program Files\Java\jdk1.8.0_60


> echo %http_platform_port%
D:\home\site\wwwroot
%http_platform_port%


> cat web.config
D:\home\site\wwwroot
<?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\web-0.0.1-SNAPSHOT.war&quot;">
</httpPlatform>
</system.webServer>
</configuration>

最佳答案

这不应该是一个可执行的 JAR 而不是 WAR 吗?您可以仅安装 JDK 8 来运行 Spring Boot JAR,但您需要一个 Java EE 应用服务器来部署 WAR。

我不知道 web.config 文件是什么;我使用 Cloud Foundry。我需要的只是一个 JAR、一个用于配置的 .yml 文件和一个 JDK。 Spring Boot JAR 中应该包含整个应用程序及其依赖项。我使用 Maven 创建 fat JAR。

关于java - 无法将 Spring Boot 应用程序部署到 Azure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35713679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com