[英]Deploying Springboot to Azure App Service
我正在嘗試將springboot項目部署到Azure應用服務中。 我創建了一個應用程序服務,並通過FTP上傳了兩個文件:test.war和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 "%HOME%\site\wwwroot\test.war"">
</httpPlatform>
</system.webServer>
</configuration>
我正在將war文件上傳到site / wwwroot,並將web.config文件也放置在那里。
我的問題是:如何執行戰爭文件? 完成自動部署后應該發生這種情況嗎? 因為現在我得到的只是服務不可用,HTTP錯誤503。
謝謝
@ItaiSoudry,根據您的web.config
文件的內容,您似乎想要使用嵌入式servlet容器(例如嵌入式tomcat或jetty)來啟動spring boot Web應用程序。
假設您使用的IDE是Eclipse,則需要將spring boot項目導出為可運行的jar文件,而不是war文件,請參見下圖。
注意:應該選擇Launch configuration
為Class,其主要功能包含SpringApplication.run
。
同時,您需要通過web.config
文件中的參數--server.port=%HTTP_PLATFORM_PORT%
將配置為%HTTP_PLATFORM_PORT%
的Azure應用服務所支持的偵聽端口,或將ServerProperties
類的端口設置為System.getenv("HTTP_PLATFORM_PORT")
。
這是帶有--server.port=%HTTP_PLATFORM_PORT%
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\test.jar"">
</httpPlatform>
</system.webServer>
</configuration>
如果要部署war文件,則需要在Azure門戶上配置ApplicationSettings
程序服務的ApplicationSettings,然后將war文件上傳到路徑wwwroot/webapps
。
作為參考,請參考以下文檔。
Springboot
小節 希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.