zoukankan      html  css  js  c++  java
  • 【Azure 应用服务】App Service 部署txt静态文件和Jar包在不同目录中的解决办法

    问题描述

    在Web App wwwroot (Windows系统中)根目录下如何部署一个jar包和一个text文件,让两个文件都能被访问?

    解决办法

    Jar包和Text文件都分别放置在两个单独的文件夹中,并且在各自的文件夹中添加web.config来指明启动方式。

    第一步:通过 App Service 门户配置页面,添加两个文件夹 test 和test1

    第二步:将txt文件放在 site\wwwroot\test 文件夹下,添加一个web.config文件来访问静态文件

    web.config内容如下:

    <?xml version="1.0"?>  
    <configuration>  
        <system.webServer>
            <handlers>
               <clear />
                <add 
                    name="StaticFile"
                    path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" 
                    resourceType="Either" 
                    requireAccess="Read" />
            </handlers>
        </system.webServer>
    </configuration>  

    第三步:将jar包放在 site\wwwroot\test1 文件夹下,添加一个web.config文件,用于启动Jar包

    web.config内容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
        </handlers>
         <!-web app的java.exe路径和jar包存放的路径->
         <httpPlatform processPath="C:\Program Files\Java\zulu11.48.21-jre11.0.11-win_x64\bin\java.exe" arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\test1\test.jar&quot;" > 
        </httpPlatform>
      </system.webServer>
    </configuration>

    第四步:部署后,在Kudu中查看文件结构如下

    第五步:重启站点,通过默认URL加\test,\test1分别访问test及jar文件内容

    参考资料

    Java HttpPlatformHandler Configuration Exampleshttps://docs.microsoft.com/zh-cn/iis/extensions/httpplatformhandler/httpplatformhandler-configuration-reference#httpplatformhandler-configuration-examples

    当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

  • 相关阅读:
    mongodb搭建
    使用systemctl管理服务
    常用命令--find
    linux中的常用信号
    bash 中的特殊变量
    tomcat开启PID文件
    django基础入门
    Redis源码编译安装
    DRF路由组件
    Django/DRF序列化
  • 原文地址:https://www.cnblogs.com/lulight/p/15760763.html
Copyright © 2011-2022 走看看