Swagger生成的代码不断被JRebel删除和重新上传 - 无休止地

时间:2017-05-08 20:21:31

标签: intellij-idea maven-3 wildfly jrebel swagger-codegen

我有一个Wildfly Rest服务,我是从Swagger jaxrs-resteasy生成的。该项目来自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.

1 个答案:

答案 0 :(得分: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还可以监控其他资源文件(Web文件,属性文件等),这些文件可以在 rebel.xml 中指定。

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

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

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

JRebel IntelliJ remote servers configuration

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