Intellij Spring Boot运行不起作用gradle bootRun

时间:2019-11-22 22:12:35

标签: java spring-boot gradle intellij-idea

我使用IntelliJ运行SpringBoot。 intellij run

group 'helloworld'

version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'
apply plugin: 'org.springframework.boot'

sourceCompatibility = 1.8

configurations {
    runtimeAgent
}

buildscript {
}

dependencies {
    runtimeAgent "org.springframework:spring-instrument"
    runtimeAgent "org.aspectj:aspectjweaver"
}

/** I want this option to work together. When run with IntelliJ **/
bootRun.doFirst {
    def springInstrument = "-javaagent:" + configurations.runtimeAgent[0].absolutePath
    def aspectJWeaver = "-javaagent:" + configurations.runtimeAgent[1].absolutePath
    applicationDefaultJvmArgs = [springInstrument, aspectJWeaver]
}

当我运行intelliJ时,我想同时运行“ bootRun.doFirst”选项。 我找不到办法。救命。谢谢。

1 个答案:

答案 0 :(得分:0)

IDE不可能从build.gradle脚本中提取所有自定义项。您将需要使用委托运行到Gradle:在“设置”中设置Gradle(macOS上的首选项)|构建,执行,部署|生成工具|摇篮| 使用构建并运行。

否则,请在“ Spring Boot运行/调试配置”中配置JVM选项: enter image description here