java - 如何将jar文件部署到azure?

标签 java azure cloud grizzly

我使用 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 &quot;%HOME%\site\wwwroot\ServerConsole-V1.jar&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

当我尝试使用浏览器或 PostMan 访问 RESTFul API 时,出现超时错误。我该如何诊断?

最佳答案

根据您的描述,您的情况类似于将jar包部署到azure Web App。 我上传了一个 spring-boot 项目作为如何将 jar 部署到 Azure Web App 的示例。

第1点请使用mvn packagepom.xml所在目录下构建JAR包code> 文件所在位置。

enter image description here ]

第2点:请确保web.config中配置的jar包名称与上传的jar包名称相同。

enter image description here

网络配置

<?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 &quot;%HOME%\site\wwwroot\<your jar name>&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

第3点:请使用FTP将jar文件web.config发布到D:\home\site\wwwroot KUDU 上的\ 目录。

第4点请确保ApplicationSettings与您的项目匹配,例如jdk版本tomcat版本

enter image description here

希望对您有帮助。

关于java - 如何将jar文件部署到azure?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47558959/

相关文章:

cloud - 我们可以找到 Google Cloud Speech API 服务器吗?

Azure维护: possible downtime with 8 instances?

java - 无法在测试中创建表(Hibernate 和 H2)

java - 字符串中的字符打乱问题

java - 客户端中域对象中的注释提取完整的 hibernate 依赖项

java - 一对多关系中的父实体更新不会删除 Spring Jpa Childs

asp.net-mvc - 将 Web API 和 MVC 项目部署到 Azure 的正确方法是什么?

Azure:为什么在 API 网关 (http) 和监听器的 SSL 证书更新期间会出现停机

azure - 使用工作(Azure AD)身份验证的 ASP.NET Core Web 应用程序可以在本地进行调试,但在发布到 Azure 后无法进行调试

linux - 如何以 root 用户身份在命令行中通过 RTSP 使用 VLC 流式传输视频?