Use Spring Initializr to generate the basic project structure. Use “Gradle Project/Java/2.0.0” options, and fill the “GroupId/ArtifactId” fields with the values you want. In this case they are “com.example/demo”. Then click the “Generate Project” button to download the zip file.
Unzip the zip file to a directory. It’s already a complete Gradle project with Spring Boot.
Update the “build.gradle” file, such as adding “idea” plugin, dependency version numbers and etc. The final content is:
bootJar { baseName = 'demo-spring-boot' version = '0.1.0' }
Now you can run the following command to generate the IntelliJ IDEA project artifacts(demo.iml/demo.ipr/demo.iws).
1 2 3 4 5 6
# If you have Gradle installed in your environment: gradle build # If you don't have Gradle installed in your Unix like OS(Linux/MacOS): ./gradlew build # If you don't have Gradle installed in your Windows: .\gradlew.bat build
After the command executes successfully, open the “demo.ipr” file in IntelliJ IDEA.
/** * Then entrance of the whole application. By default the application is a stand-alone Java application. If you * want to create a deployable war file, please following the instructions * [here](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file). */ @SpringBootApplication publicclassDemoApplication {