Spring Boot

 Different options of creating Spring Boot projects with Maven and Eclipse


1. Spring Initializr 

https://start.spring.io

2. STS (Spring Tool Suite) Eclipse Plugin             

https://www.eclipse.org/community/eclipse_newsletter/2018/february/springboot.php

3. Manually Create a Maven Spring Boot Project

    - Create Maven Project

 -  Provide Group id, Artifact Id, and version

- Add in the appropriate Spring Boot starters into the pom.xml 

<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> 

- Add a Spring Boot starter parent as the parent pom in the pom.xml

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M6</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

- Configure Java version

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

- Create a Spring Boot application class that will be the launching point of the web application.

package com.vasanth.spring;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication; 

@SpringBootApplication

public class SpringBootWebApplication {

    public static void main(String[] args) {

        SpringApplication.run(SpringBootWebApplication.class, args);

    }

}

When you launch this class as a Java application, you will see that an embedded Tomcat server launches, and you are ready to add features to this application.

Major features in spring-boot:

  • Starter Dependencies
  • Auto Configurations
  • Command-line Interface(CLI)
  • Actuators

The following things can be seen using actuator api.

What are the been configured in the application context?
What are the things auto-configured?
Can see all the variables and properties have been set 
Memory utilization and garbage collection, resources
Recent HTTP Requests handled by the application.


Spring Framework Annotations: 

https://springframework.guru/spring-framework-annotations/ 


Spring Boot JPA + H2 example: Build a CRUD Rest APIs

Refer this site : https://bezkoder.com/spring-boot-jpa-h2-example/ 

Demo : https://github.com/vthangar0202/springboot_jpa_h2.git



Comments

Popular posts from this blog

Java Design Patterns