我正在尝试将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文件也放置在那里。
我的问题是:我该如何执行war文件?完成自动部署后应该发生这种情况吗?原因现在我得到的只是“服务不可用,HTTP错误503”。
谢谢
@ItaiSoudry,根据web.config
文件的内容,您似乎想要使用嵌入式servlet容器(例如嵌入式tomcat或jetty)来启动Spring Boot Web应用程序。
假设您使用的IDE是Eclipse,则需要将spring boot项目导出为可运行的jar文件,而不是war文件,请参见下图。
注意:Launch configuration
应该选择主要功能包含的Class SpringApplication.run
。
同时,你需要配置监听端口与%HTTP_PLATFORM_PORT%
通过参数所支持的应用程序Azure的服务--server.port=%HTTP_PLATFORM_PORT%
中web.config
的文件或设置类的端口ServerProperties
与价值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 "%HOME%\site\wwwroot\test.jar"">
</httpPlatform>
</system.webServer>
</configuration>
如果要部署war文件,则需要ApplicationSettings
在Azure门户上配置应用程序服务的,然后将war文件上传到path中wwwroot/webapps
。
作为参考,请参考以下文档。
Springboot
本文https://azure.microsoft.com/zh-CN/documentation/articles/web-sites-java-custom-upload/#application-configuration-examples中的小节希望能帮助到你。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句