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

发布于 2021-02-02 11:44:24

我无法让Spring Boot站点对Azure Web实例进行响应。我已遵循Java应用程序说明和上传说明。看来IIS服务器正在接收请求,但是战争中的servlet没有响应。根据文档,有一些陷阱。特别是,应将web.config部署到wwwroot并指定java路径以及转发端口。我相信我已经涵盖了这些基础-我的web.config粘贴在下面。

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

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

应用设置:

应用程式设定

Azure控制台信息(Env变量和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>
关注者
0
被浏览
99
1 个回答
  • 面试哥
    面试哥 2021-02-02
    为面试而生,有面试问题,就找面试哥。

    那不应该是可执行的JAR而不是WAR吗?您可以仅安装JDK 8来运行Spring Boot JAR,但是需要Java EE应用服务器才能将WAR部署到其中。

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



知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看