更改静态内容(html,css,JS)无需重启服务器



静态内容,如HTML, CSS, JavaScript的变化不影响页面刷新。它需要重新启动服务器以应用更改。但有趣的是,只有前两次更改应用于页面重新加载。但从第三次更改开始,看不到更改,只有第二次更改的内容才能看到。内容存在于war文件夹中。我需要在standalone .xml中更改什么?我尝试了"静态内容",并添加了jboss论坛中提到的处理程序,但它似乎不起作用。如果需要进一步的信息,请告诉我。

您需要启用爆炸内容的自动部署。该选项在standalone.xml配置文件中作为deployment-scanner元素的auto-deploy-exploded属性提供:

    <subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
        <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-zipped="true" auto-deploy-exploded="true"/>
    </subsystem>

要成功实现此目标,请执行以下操作:

  1. 启动服务器
  2. 把你的WAR文件夹(例如foo.war)放到部署文件夹中。它必须是一个解压缩的目录结构,而不是单个WAR文件
  3. 服务器应该部署
  4. 内容
  5. 修改文件夹
  6. 中的任何内容
  7. 服务器应该重新部署
  8. 内容

请注意(服务器也会警告你)这是不稳定的行为,不适合生产环境。

编辑

您还可以为特定路径使用自定义处理程序,参见下面的配置(省略了不相关的部分)。这样你就不需要每次修改都重新部署了。

     <subsystem xmlns="urn:jboss:domain:undertow:1.2">
         <buffer-cache name="default"/>
         <server name="default-server">
             <http-listener name="default" socket-binding="http"/>
             <host name="default-host" alias="jboss.local">
                 <location name="/" handler="welcome-content"/>
                 <location name="/static" handler="static"/>
             </host>
         </server>
         <handlers>
             <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
             <file name="static" path="/Users/miso/static-files" directory-listing="false"/>
         </handlers>
     </subsystem>

最新更新