我使用 grizzly 和 google guice 创建了一个 RESTFul 服务。我可以在命令行上运行它:
c:\Java\src\options\console>java -jar target\ServerConsole-V1.jar
Nov 28, 2017 3:18:01 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
web server started successfully at http://localhost:8080/
...press any key to stop the process
现在我想将此服务部署到云端。我找到了有关部署 SpringBoot 应用程序和使用 jar 文件创建 webjobs 的文章,但这些文章都不适用于我的应用程序的工作方式。
我是否必须重新设计网络服务器(以 Spring 启动)或者我可以按原样部署它吗?如果是这样,怎么办?
谢谢,马特
编辑: 我已按照下面的 Jay 步骤进行操作。我创建了一个 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=8080 -jar "%HOME%\site\wwwroot\ServerConsole-V1.jar"">
</httpPlatform>
</system.webServer>
</configuration>
当我尝试使用浏览器或 PostMan 访问 RESTFul API 时,出现超时错误。我该如何诊断?
最佳答案
根据您的描述,您的情况类似于将jar包部署到azure Web App。 我上传了一个 spring-boot 项目作为如何将 jar 部署到 Azure Web App 的示例。
第1点请使用mvn package
在pom.xml
所在目录下构建JAR包code> 文件所在位置。
第2点:请确保web.config中配置的jar包名称与上传的jar包名称相同。
网络配置
<?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\<your jar name>"">
</httpPlatform>
</system.webServer>
</configuration>
第3点:请使用FTP将jar文件
和web.config
发布到D:\home\site\wwwroot KUDU 上的\
目录。
第4点请确保ApplicationSettings
与您的项目匹配,例如jdk版本
、tomcat版本
。
希望对您有帮助。
关于java - 如何将jar文件部署到azure?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47558959/