1

我有一个从 Swagger jaxrs-resteasy 生成的 Wildfly Rest 服务。该项目来自 Jetbrains IntelliJ Idea IDE,我也在运行 jrebel。整个设置一切正常,除了来自 src/gen/java 路径的所有代码(生成的代码)不断被 JRebel 删除和上传。我是否遗漏了 rebel.xml 文件中的某些内容以使其停止执行此操作?

JRebel 控制台不断循环显示以下消息,我担心电量很快就会足以为特斯拉充电......

[2017-05-08 16:10:14] Synchronization took 189 ms in total.
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Connecting to server to sync project
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/RestApplication.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/TaxDataResponse.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/StringUtil.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/ApiOriginFilter.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/ApiResponseMessage.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/AuthenticateApiService.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/RFC3339DateFormat.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/UserDefined.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig$1$1.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/AuthenticationRequest.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/NotFoundException.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/TaxApiService.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/ChargeItemType.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig$1.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/ApiException.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig$1$2.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Upload succeeded in 147 ms. Transaction took 173 ms.
[2017-05-08 16:10:21] Synchronization took 205 ms in total.
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Connecting to server to sync project
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/RestApplication.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/UserDefined.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/RFC3339DateFormat.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/TaxDataResponse.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/StringUtil.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/ApiOriginFilter.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/ApiResponseMessage.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/AuthenticateApiService.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig$1$1.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/NotFoundException.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/AuthenticationRequest.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/TaxApiService.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/ChargeItemType.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig$1.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/ApiException.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig$1$2.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Upload succeeded in 178 ms. Transaction took 197 ms.
[2017-05-08 16:10:24] Synchronization took 197 ms in total.
4

1 回答 1

1

我怀疑问题出在rebel.xml中,尽管您可以先从一个非常简单的rebel.xml开始,然后从那里继续进行验证,在您的情况下,以下应该是一个好的开始:

<?xml version="1.0" encoding="UTF-8"?>
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">
    <classpath>
        <dir name="/absolute/path/to/project/target/classes">
        </dir>
    </classpath>
</application>

最初,JRebel 进行一次同步,删除所有旧文件并上传新文件,之后 JRebel 开始监视本地构建目录 (../target/classes/) 中的所有文件更改,并在检测到时间戳更改后触发同步事件. 如果文件 md5 哈希值与之前不同,则会上传。

此外,JRebel 还可以监视可以在rebel.xml中指定的其他资源文件(Web 文件、属性文件等)。

很难说到底发生了什么,但我的猜测是,由于某种原因,生成的文件经常被重新编译(可能是自动生成的时间戳)并且 JRebel 检测到这些文件的哈希值发生了变化。您可以手动检查文件哈希并验证是否是这种情况。

如果出于某种原因,IDEA 不断重新编译和更改 .class 文件,您可以禁用 JRebel 在每次构建后自动同步。在这种情况下,您必须在需要时手动与远程服务器同步。

Help > JRebel > Configuration > Remote Servers > "Synchronize on build"

JRebel IntelliJ 远程服务器配置

为了弄清楚确切的原因,请将rebel.ide.log=trace添加到{user.home}/.jrebel/jrebel.properties,重新启动 IDE 并重现问题,日志将生成为jrebel-intellij.log。将其发送至support@zeroturnaround.com,他们将能够为您提供更多详细信息。

于 2017-05-09T06:52:19.353 回答