[英]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.