【问题标题】:JRebel do not detect web resource changes over multiple webapp foldersJRebel 不检测多个 webapp 文件夹上的 web 资源更改
【发布时间】:2015-03-05 13:56:56
【问题描述】:

我有一个模块化的网络项目,因此我允许模块成为一个战争档案,包括 webapp 文件夹。使用以下 rebel.xml 可以很好地检测所有模块的类更改。但是由于某种原因,当 html 或 js 更改时,jrebel 不会移动。

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com"
             xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">

    <classpath>
        <!-- appserver -->
        <dir name="/home/xx/data/appserver/target/classes/main"/>
        <dir name="/home/xx/data/appserver/target/resources/main"/>

        <!-- module -->
        <dir name="/home/xx/data/as.module.core/target/classes/main"/>
        <dir name="/home/xx/data/as.module.core/target/resources/main"/>

        <dir name="/home/xx/data/as.module.mqlcore/target/classes/main"/>
        <dir name="/home/xx/data/as.module.mqlcore/target/resources/main"/>
    </classpath>

    <!-- web>
        <link target="/">
            <dir name="/home/xx/data/appserver/src/main/webapp"/>
            <dir name="/home/xx/data/as.module.core/src/main/webapp"/>
            <dir name="/home/xx/data/as.module.mqlcore/src/main/webapp"/>
        </link>
    </web -->

    <web>
        <link target="/">
            <dirset dir="/home/xx/data">
                <include name="**/src/main/webapp"/>
            </dirset>
        </link>
    </web>
</application>

编辑:

有趣的事实是。当我使用 web 配置的注释部分时,所有三个 webapp 文件夹都在日志中,并将被监视更改。但是应用服务器找不到所有的 webapp 文件。当我使用第二个&lt;web&gt; 配置时,应用程序服务器可以看到所有文件,但 jrebel 不会观察到所有文件。我认为不可能有多个目录链接到“/”

【问题讨论】:

    标签: java jrebel


    【解决方案1】:

    每个模块,例如 .war 或 .jar 文件都需要有自己的 rebel.xml 文件。否则它们都将重新加载相同的资源,并且当拥有不同的类加载器时,可能会发生各种奇怪的事情。

    可以通过从 jrebel.log 中搜索“找到的资源”来检查 JRebel 实际使用的文件实例。应该写成这样 sun.misc.Launcher$AppClassLoader@184be29 找到资源:来自“file:/C:/Projects/testproject/Trunk/edm/target/cfg/log4j.xml”的资源:“cfg/log4j.xml”。

    还可以通过使用 Event 查找行来查看更改了哪个文件,如下所示: [IntelliJFSNotify] 事件 'CHANGE' on: 'C:/Projects/testproject/Trunk/edm/target/cfg/log4j.xml'

    如果不重新加载文件,通常找到的资源和更改的文件路径不匹配。如果它们确实匹配,则建议将文件的绝对路径和 jrebel.log 发送到 support@zeroturnaround.com 进行调查。

    【讨论】:

    • 实际上在 webapp 的类路径中有一个联合 rebel.xml 是一种有效的方案。由于所有模块类(不是 jars)都部署到同一个 war(以及展开的 war 文件夹结构)中,因此不需要额外的 rebel.xmls。将简单地相互覆盖。有趣的是,在日志中我可以找到 JRebel: Reloading class 'xxx'。但在更改 html 文件时根本没有。也许我可以调整 jrebel 的日志级别
    • 启动网络服务器时有几个:JRebel: Directory '.../resources/main' will be monitored for changes。但是列出的目录都是类和资源,但不是 rebel.xml 中用 指定的“webaps”
    • @Margus,我已经为我的所有模块生成了一个 web.xml,它们存在于 jar 文件中,但 jrebel 只加载了 web 战争中的单个模块。我不知道为什么。
    【解决方案2】:

    好的,答案是:确实不能在&lt;web&gt;&lt;link target="/"&gt;&lt;/link&gt;&lt;/web&gt;配置下配置多个目录。我现在有一个文件夹 ./target/all-webapp ,我在其中通过 gradle 任务对所有文件进行 smylink (cp -sR) ... 不好但可以工作...感谢上帝 jrebel 正在关注符号链接!

    【讨论】:

    • 这个变通办法很有效。但是,JRebel 支持一个模块具有多个源目录的情况。如果您尝试更改文件及其对 JRebel 支持的绝对路径,可以调查为什么它在您的情况下不起作用。
    猜你喜欢
    • 2012-07-28
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-25
    • 2016-05-17
    相关资源
    最近更新 更多