Intellij spring boot expand processResources in gradle build file to replace properties

Property fields are properly replaced when built from the command line using the command gradle build, but this is not the case when used IntelliJ IDEA IDE.

code in build.gradle

ext {
    port = 8086
}

processResources {
    filesMatching('application.properties') {
        expand(project.properties)
    }
}

the code application.properties

server.port = ${port}
+6
source share
4 answers

When you launch the Spring boot application in IntelliJ by clicking on the β€œRun” button, it starts with a regular java command and virtually no gradle tasks. Therefore, the task processResourcesdoes not start.

IntelliJ, gradle bootRun. IntelliJ gradle , , Tasks, application, bootRun.

IntelliJ, , gradle bootRun.

/ IntelliJ, IDE buide/run gradle, " | Build, Exectuion, | | gradle | Runner.

+4

- . , , / IntelliJ, , , gradle.

: , spring ?

0

. , intellij run:

  • Gradle processResources
  • VM gradle: -Dorg.gradle.project.buildDir=out/production. Gradle , intellij.
0
source

From your question, I understand that in intellij your variable is ${port}not displayed. In Intellij, using your gradle tool, run the command clean buildto perform a new build. Check your console log for a message that may tell us what might happen.

-1
source

Source: https://habr.com/ru/post/1654274/


All Articles