Java 将Springboot部署到Azure应用程序服务
我正在尝试将我的springboot项目部署到Azure应用程序服务中。 我创建了一个应用程序服务,并通过FTP上传了两个文件:test.war和web.config,正如他们在教程中提到的那样 web.configJava 将Springboot部署到Azure应用程序服务,java,azure,web-applications,spring-boot,Java,Azure,Web Applications,Spring Boot,我正在尝试将我的springboot项目部署到Azure应用程序服务中。 我创建了一个应用程序服务,并通过FTP上传了两个文件:test.war和web.config,正如他们在教程中提到的那样 web.config <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers> <add name="httpPl
<?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文件上载到站点/wwwroot,并将web.config文件也放在那里
我的问题是:如何执行war文件?当我自动完成部署时应该发生吗?因为现在我得到的只是服务不可用,Http错误503
感谢@ItaiSoudry,根据
web.config
文件的内容,您似乎希望使用嵌入式servlet容器(如嵌入式tomcat或jetty)来启动spring boot web应用程序
假设您使用的IDE是Eclipse,您需要将spring引导项目导出为可运行的jar文件,而不是war文件,请参见下图
注意:Launch配置
应选择主函数包含的类SpringApplication.run
同时,您需要使用%HTTP\u PLATFORM\u port%
通过web.config
文件中的参数--server.port=%HTTP\u PLATFORM\u port%
配置侦听端口,或者使用值System.getenv(“HTTP\u PLATFORM\u port”)
设置类的端口
下面是一个使用--server.port=%HTTP\u PLATFORM\u 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>
作为参考,请参考以下文件
本文中的Springboot
小节
希望有帮助。这里我已经给出了详细的步骤,请检查-