将Springboot部署到Azure App Service [英] Deploying Springboot to Azure App Service

查看:93
本文介绍了将Springboot部署到Azure App Service的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将springboot项目部署到Azure App Service中. 我创建了一个应用服务,并通过FTP上传了两个文件:test.war和web.config,如其教程中所述.

I'm trying to deploy my springboot project into Azure App Service. I created an App Service and uploaded via FTP two files: test.war and web.config as mentioned in their tutorials.

web.config

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\test.war&quot;">
    </httpPlatform> 
  </system.webServer>
</configuration>

我正在将war文件上传到site/wwwroot,并将web.config文件也放置在其中.

I'm uploading the war file into the site/wwwroot and placed the web.config file there as well.

我的问题是:如何执行war文件?完成自动部署后应该发生这种情况吗?原因现在我得到的只是服务不可用,HTTP错误503.

My question is: How do I execute the war file? is it supposed to happen when I finish deploy automatically? cause right now all I get is Service Unavailable, Http Error 503.

谢谢

推荐答案

@ItaiSoudry,根据您的web.config文件的内容,您似乎想要使用嵌入式servlet容器(例如嵌入式tomcat或jetty)来启动Spring Boot Web应用程序.

@ItaiSoudry, According to the content of your web.config file, it seems that you want to use the embedded servlet container like embedded tomcat or jetty to start up the spring boot web application.

假设您使用的IDE是Eclipse,则需要将spring boot项目导出为可运行的jar文件,而不是war文件,请参见下图.

Assumption that the IDE you used is Eclipse, you need to export your spring boot project as a runnable jar file, not a war file, please see the figure below.

注意:Launch configuration应该选择为主函数包含SpringApplication.run的Class.

Note: The Launch configuration should be selected the Class which the main function contains SpringApplication.run.

同时,您需要使用%HTTP_PLATFORM_PORT%通过web.config文件中的参数--server.port=%HTTP_PLATFORM_PORT%支持的Azure App服务配置监听端口,或设置类.

Meanwhile, you need to configure the listen port with %HTTP_PLATFORM_PORT% the Azure App service supported via the argument --server.port=%HTTP_PLATFORM_PORT% in the web.config file or set the port of the class ServerProperties with the value System.getenv("HTTP_PLATFORM_PORT").

这是web.config--server.port=%HTTP_PLATFORM_PORT%的示例.

<?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\test.jar&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

如果要部署War文件,则需要在Azure门户上配置应用程序服务的ApplicationSettings,然后将war文件上传到路径wwwroot/webapps.

If you want to deploy a war file, you need to configure the ApplicationSettings of your app service on Azure portal, then upload the war file into the path wwwroot/webapps.

作为参考,请参阅以下文档.

As references, please refer to the documents below.

  1. 文章Springboot小节"rel =" noreferrer> https://azure.microsoft.com/zh-CN/documentation/articles/web-sites-java-custom-upload/#application-configuration-examples
  2. 在Azure中创建Java Web应用应用服务
  1. The Springboot subsection in the article https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/#application-configuration-examples
  2. Create a Java web app in Azure App Service

希望有帮助.

这篇关于将Springboot部署到Azure App Service的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆