javascript
jrebel gradle_JRebel适用于Gradle Spring Boot应用程序
jrebel gradle
關(guān)于如何將JRebel添加到使用Gradle作為構(gòu)建工具的Spring Boot應(yīng)用程序中,有一些文檔 。 它是基本的,但是效果很好。
您所要做的就是在build.gradle中添加幾行:
if (project.hasProperty('rebelAgent')) {bootRun.jvmArgs += rebelAgent }然后在gradle.properties中設(shè)置屬性:
rebelAgent=-agentpath:[path/to/JRebel library]但是,有幾種方法可以對(duì)此進(jìn)行改進(jìn)。
使JRebel成為可選
例如,如果您每次使用' bootRun'啟動(dòng)應(yīng)用程序時(shí)都不總是想要JRebel怎么辦? 像Intellij IDEA這樣的IDE的JRebel插件足夠聰明,可以讓您選擇是否使用JRebel來運(yùn)行您的應(yīng)用程序
這樣做有幾種方法,但是一種方法是在可選任務(wù)中添加JRebel啟動(dòng)配置。
task addRebelAgent << {if (project.hasProperty('rebelAgent')) {bootRun.jvmArgs += rebelAgent}elseprintln 'rebelAgent property not found' }task rebelRun(dependsOn: ['addRebelAgent', 'bootRun'])現(xiàn)在運(yùn)行“ bootRun”將正常啟動(dòng)該應(yīng)用程序,如果要使用JRebel,請(qǐng)改用“ rebelRun”任務(wù)。 如果'rebelAgent'屬性不可用,我還添加了一條調(diào)試消息。
另一種方法是將可選屬性傳遞給“ bootRun”任務(wù),以用作是否添加JRebel的標(biāo)志。
if (project.hasProperty('rebelAgent') &&project.hasProperty('addJRebel')) {bootRun.jvmArgs += rebelAgent }然后,要使用JRebel,您只需添加多余的屬性。
gradle bootRun -PaddJRebel = true
尋找叛軍基地
在屬性文件中放置JRebel庫的路徑以用作代理,可使多個(gè)開發(fā)人員擁有自己的版本。 但是,路徑仍然是硬編碼的,如果可能的話,應(yīng)該避免這種情況。
指定路徑的另一種方法是使用系統(tǒng)環(huán)境變量指向JRebel的安裝位置。 JetBrains建議使用REBEL_BASE 。 設(shè)置好之后,您就可以通過多種方式使用環(huán)境變量,例如Gradle構(gòu)建文件,命令行,構(gòu)建腳本等。
這是一個(gè)示例,該示例使用了我之前在Windows 64計(jì)算機(jī)上使用的其他“ addRebelAgent”任務(wù)。
task addRebelAgent << {project.ext {rebelAgent = "-agentpath:${System.env.REBEL_BASE}${rebelLibPath}"}if (project.hasProperty('rebelAgent')) {bootRun.jvmArgs += rebelAgent}elseprintln 'rebelAgent property not found' }task rebelRun(dependsOn: ['addRebelAgent', 'bootRun'])在gradle.properties中,我從JRebel安裝位置指定了到代理庫的路徑。
rebelLibPath=\\lib\\jrebel64.dll我在這里所做的只是在REBEL_BASE環(huán)境變量的'rebelAgent'屬性中構(gòu)建路徑,以及在另一個(gè)指定庫內(nèi)部路徑的屬性中構(gòu)建路徑。
rebelAgent = "-agentpath:${System.env.REBEL_BASE}${rebelLibPath}"翻譯自: https://www.javacodegeeks.com/2018/02/jrebel-gradle-spring-boot-app.html
jrebel gradle
總結(jié)
以上是生活随笔為你收集整理的jrebel gradle_JRebel适用于Gradle Spring Boot应用程序的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 无线路由器ip地址怎么设置(无线路由器I
- 下一篇: 电脑看漫画的app下载(用电脑画漫画的软