Friday, 14 December 2018

How to create the Spring Boot Project using Spring Initializr tool ?

        In the previous post, we discussed the usage and example of @SpingBootApplication annotation. Current post, will discuss about to create the Spring boot application using Spring Initializr.

        One of the difficult things to start with a framework is initial setup, particularly if you are starting from scratch and you don't have a reference setup or project, Spring Initialzr solve this problem.
 
      Spring Initiliazr is a web tool provided by Spring to create the Spring boot application. It is helpful for the beginner, it will create the initial set up or project structure. 

Spring Initialzr URL : Spring Initilazr


Select Maven project and dependencies. Fill other details like Group, Artifact and click on generate project.

I have selected Web, JPA, DevTools and Actuator as dependencies.
Spring Initializr

When click on "Generate Project" , it will ask for download project, will download the zip file.

Extract the downloaded project file, and import into eclipse tool.
Import project in eclipse


Select Existing Maven Project, browse the extracted project directory.



Next,

Browse project directory

Now the Demo project is imported into eclipse,

The project structure it looks like below,




The main class DemoApplication.java,


Spring boot Application class

The pom.xml,

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.1.1.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
 </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

 <properties>
       <java.version>1.8</java.version>
 </properties>

 <dependencies>
      <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-actuator</artifactId>
      </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
      </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-devtools</artifactId>
          <scope>runtime</scope>
      </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
      </dependency>
 </dependencies>

 <build>
    <plugins>
       <plugin>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-maven-plugin</artifactId>
       </plugin>
    </plugins>
 </build>

</project>

Thank you for visiting blog...


Related Posts:--
1) The @SpringBootApplication Annotation usage and example
2) Explain advantages of Spring Boot
3) Causes and Solution of NoSuchBeanDefinitionException in Spring.
4) Cause and solution of LazyInitializationException in Hibernate

No comments:

Post a Comment