官术网_书友最值得收藏!

Using a web interface for Spring Initializr

The Spring team provides a web application hosted at: https://start.spring.io. It is the most simple way to create a Spring Boot application and the most straightforward way to use the Spring Initializr. It has all the menu options for you, just choose them and use them in your application.

Let's see the following screenshot of what the home page look like:

As you can see, there are a number of options you need to fill in. They are:

  • Project type: Maven or Gradle
  • Language: Java, Kotlin, or Groovy
  • Spring Boot version

On the SPRING INITIALZR home page, on the left side of the form, it asks to specify minimum project metadata, so you must provide the project's Group and Artifact.

You can enter minimal details for whatever SPRING INITIALZR asks about your application, pick your build system, favorite language, and version of Spring Boot you wish to use, whatever you want. After that, choose your application's dependencies from the menu and also provide your project's Group and Artifact. Click the Generate Project button, and we have a ready-to-run application.

Here, I have selected the Spring Boot 2.0.2, Maven build from the drop-down menu and Java as the language from the drop-down menu. Next, I have given my project's Group and Artifact as follows:

  • Groupcom.dineshonjava.masteringspringboot
  • Artifactmastering-spring-boot

Let's see another interesting thing about the web-based interface. Once you click the Switch to the full version link at the bottom of the web interface, it expands to provide more options. It lets you pick the ingredients for your application, like picking off a delicious menu. And also, you can specify additional metadata such as version and base package name.

As you can see in the previous screenshot, I have added some more ingredients such as project description, package name, packaging style (either JAR or WAR), and you could also choose a Java version as well. Let's click on the Generate Project button on the form to have Spring Initializr generate a project for you.

Spring Initializr presents this project to you as a ZIP file, named as the value in the Artifact field, that is downloaded by your browser. In our case, this ZIP file is named mastering-spring-boot.zip.

Let's unzip this file and you will have a project structure as follows:

As you can see, there's very little code in this project and it also creates a couple of empty directories. The generated project contains the following:

  • pom.xml: A Maven build specification
  • MasteringSpringBootApplication.java: A class with a main() method to bootstrap the application
  • MasteringSpringBootApplicationTests.java: An empty JUnit test class instrumented to load a Spring application context using Spring Boot auto-configuration
  • application.properties: An empty properties file for you to add configuration properties to as you see fit
  • static directory: Here, you can put any static content (JavaScript, style sheets, images, and so on) to be served from the web application
  • templates directory: Here, you can put templates that render model data

Finally, import this project to your favorite IDE. If you are using the Spring Tool Suite IDE, it supports creating Spring Boot applications, so you don't need to go to the web-based interface.

Let's have a look at how to create a Spring Boot project by using the STS IDE.

主站蜘蛛池模板: 任丘市| 亳州市| 龙江县| 林口县| 平顶山市| 鄂尔多斯市| 宝鸡市| 漠河县| 遂昌县| 钦州市| 定结县| 西盟| 朝阳县| 大庆市| 锡林浩特市| 岑溪市| 东台市| 南昌市| 邹城市| 博白县| 青岛市| 泰州市| 罗源县| 土默特左旗| 同德县| 桂东县| 霍山县| 新昌县| 深泽县| 麻栗坡县| 固安县| 武平县| 砚山县| 嘉祥县| 平凉市| 竹山县| 边坝县| 张家川| 永嘉县| 德州市| 乃东县|