As mentioned in previous posts, Spring Boot is a Framework that allows as to accelerate our development, helping us with some configurations, in this post we will see how we can take advantage of these automatic configurations creating a simple application using Spring Initializr
If you don't not what Spring Boot is, I recommend you to go to (What is Spring Boot?) and read a brief introduction about Spring Boot.
We have multiples opciones to create a project using Spring Boot: the fisrts one is using the web version of Spring Intializr, the second one through an IDE like Spring Tool Suite (STS) or Intelij and the third using the CLI or command line interface, we are gooign to learn how to create a project using de web version of Spring Initializr and using de STS IDE
In order to maintain this posts as simple as posible we are goin to create a simple project that stores product information in a Mysql data base
Let's start by creating project using Spring Initializar:
- First we need to access to the web version of Spring Initialize through this link (Spring initializr,) o searching Spring initializr in Goole, you will see a page like the one shown in the following image:
One you are in the Spirng Intiliazr page, you have to fill some fileds request by the tool:
- Choose Maven Project as dependency manager
- Choose the latest stable version of Spring Boot, in this case V 2.2.2
- In the project metadata option fill the fill the following fields:
- Group Id: co.com.bateacode.products
- Artifac Id (nombre de nuestra aplicación) ingresamos: approducts
- Finally choose the dependencies: Spring web, Thymeleaf y Spring Data JPA,
as shown in the following image:
One you have completed the by the Spring Innitializr tool, you have to clic on Generate Button to generar the project:
This tool will generate a Zip file, unzip the file in the STS workspace
To import the project in Spring STS you have to follow the next steps:
Open Spring STS, Click in File, the click in Import, choose the option Existing Maven Prorject and Finally clic in the Next button:
Choose the path of the project you have downloaded from Spring web Intializr, clicking in the Brose button:
Finally clic in the Finish button to import the maven project:
this image show the structure of our project:
2. The second option to create a project using Spring Boot is through some IDE, we are goin tho show how to perform this task using Spirng STS IDE:
Open STS, choose File, click in New, then clic in Spring Starter Project:
you will see a windows where you can fill the fields to create the project, if you notice this fields are almost the same that we filled in the web version of Spring Initializr:
The next step is to choose the dependency, you can search those dependencies in the search field and then add it to the project:
Finally click in the Finish button, and then you can see the project structure:
As you can see, creating a project using Spring Intializr is simple and straightforward, Spring Boot manage some dependencies for us and automate some task that we will explain in future posts, additionally we are goin to incremental develop our simple products app, so stay tuned for future posts.
No hay comentarios.:
Publicar un comentario