2017-05-08 88 views
1

我有一個從Swagger jaxrs-resteasy生成的Wildfly Rest服務。該項目是來自Jetbrains IntelliJ Idea IDE的maven,我也在運行jrebel。除了來自src/gen/java路徑的所有代碼(生成的代碼)不斷被JRebel刪除和上傳之外,所有的設置都能很好地工作。我是否在rebel.xml文件中丟失了某些內容讓它停止執行此操作?Swagger生成的代碼不斷被JRebel刪除並重新上傳 - 無休止地

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. 
+0

新信息:我有IntelliJ安裝程序自動構建。關閉此功能會停止連續的JRebel部署和非部署週期。奇怪的是,唯一受影響的代碼是src/main/java之外的代碼(即:/ src/gen/java),所以我仍然認爲即使IntelliJ自動構建,JRebel也應該可以正常運行。 –

回答

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中指定。

很難說出究竟發生了什麼,但我猜測由於某種原因,生成的文件經常會重新編譯(可能是自動生成的時間戳),JRebel會檢測這些文件的哈希值變化。您可以手動檢查文件哈希值並驗證可能是這種情況。

如果由於某種原因,IDEA會不斷重新編譯和更改.class文件,您可以在每次構建後禁用JRebel自動同步。在這種情況下,您必須在需要時手動與遠程服務器進行同步。

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

JRebel IntelliJ remote servers configuration

搞清楚確切的原因,請加rebel.ide.log =跟蹤{}的user.home /。JRebel的/ jrebel.properties,重新啓動IDE並重現該問題,日誌將生成爲jrebel-intellij.log。發送到[email protected],他們將能夠爲您提供更多的細節。

+0

如果我將IntelliJ設置爲不自動生成,行爲將停止。由於該問題僅影響來自src/main/java之外的代碼(即:來自src/gen/java),我仍然認爲必須有一種方法來設置JRebel以不連續部署,因爲如果intelliJ運行時自動構建,只有來自src/gen/java的代碼被持續重新部署,而不是來自src/main/java的代碼或來自src/test/java的代碼。 –

+0

是的,這是可能的。我編輯了我原來的答案。 –