Azure已上传jar,但未运行它(春季启动) [英] Azure uploaded jar but doesn't run it (Spring boot)

查看:90
本文介绍了Azure已上传jar,但未运行它(春季启动)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有一个Azure Web App Service和一个SQL数据库.我正在使用Azures Intellij插件来在Web App上运行".问题是,它什么也没运行,但是确实将罐子放到了文件夹中:

Connecting to FTP server...
Uploading artifact to: /site/wwwroot/ROOT.jar ...
Uploading successfully...
Start Web App...
Logging out of FTP server...
Deploy successfully!

然后,我使用控制台尝试使用java -jar ROOT.jar运行ROOT.jar,但收到错误消息

Java不被识别为内部命令或外部命令

在webapp应用程序设置中,我有Java Version: Java 8,所以我认为它可以让我运行Java,但这只是让我怀疑我的操作方式.我部署该应用程序是否错误?

解决方案

听起来您的SpringBoot项目缺少web.config文件,该文件将部署在路径wwwroot上,以帮助处理您的ROOT.jar.

这是SpringBoot可运行jar的样本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 &quot;%HOME%\site\wwwroot\ROOT.jar&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

如上所述,它来自我对类似的SO线程的回答将Springboot部署到Azure您可以参考的应用服务.

I've got myself an Azure Web App Service and a SQL database to go with it. I'm using Azures Intellij plugin to "Run On Web App". Issue is, it doesn't run anything, however it does put the jar in the folder:

Connecting to FTP server...
Uploading artifact to: /site/wwwroot/ROOT.jar ...
Uploading successfully...
Start Web App...
Logging out of FTP server...
Deploy successfully!

I then, using console try to run the ROOT.jar by using java -jar ROOT.jar, but I get the error message

Java is not recognised as an internal command or external command

In the webapp application settings I have Java Version: Java 8 So I'd assume it'd give me the ability to run java, but this has just made me question the way I'm doing it. Am I deploying the app wrong?

解决方案

It sounds like your SpringBoot project lacked a web.config file which will be deployed at the path wwwroot for helping to handle your ROOT.jar.

Here is a sample web.config file for SpringBoot runnable 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 &quot;%HOME%\site\wwwroot\ROOT.jar&quot;">
    </httpPlatform>
  </system.webServer>
</configuration>

As above, it comes from my answer of a similar SO thread Deploying Springboot to Azure App Service which you can refer to.

这篇关于Azure已上传jar,但未运行它(春季启动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆