Azure uploaded jar but doesn't run it (Spring boot)

你说的曾经没有我的故事 提交于 2019-12-02 17:43:46

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/53732486/azure-uploaded-jar-but-doesnt-run-it-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!