Skip to content

Instantly share code, notes, and snippets.

@saurav28
Last active May 6, 2021 09:04
Show Gist options
  • Save saurav28/9dd8224b4b460d6106b8e6dd2d9eae19 to your computer and use it in GitHub Desktop.
Save saurav28/9dd8224b4b460d6106b8e6dd2d9eae19 to your computer and use it in GitHub Desktop.
Create a Spring Boot Application from Spring Initializer using Maven as the build management.
Import the project in Eclipse.
Run the project using ./mvnw spring-boot:run -DSkipTests
Develop a Rest Controller for exposing the Rest APIs . Annonate the controller class with @RestController
Generated application has the main class annotated with @SpringBootApplication
Thymeleaf UI
Create a Controller class with @Controller annonation
Keep returning the View as string.
The View file
Spring boot actuator : https://www.baeldung.com/spring-boot-actuators
Spring Boot JPA
Traditionally, JPA “Entity” classes are specified in a persistence.xml file. With Spring Boot, this file is not necessary and “Entity Scanning” is used instead. By default, all packages below your main configuration class (the one annotated with @EnableAutoConfiguration or @SpringBootApplication) are searched.
Cowin vaccine availability
1. Create a spring boot app which polls Cowin API and sends mail on availability
2. Created a Spring scheduled job to poll the Cowin APIs
3. Used Spring Web client to execute the HTTP requests. This is a reactive library
4. Json Response is returned from the Web client.
5. Json response is deserialized using Jackson.
6. To map the Json structure in the response created the Java model classes.
7. Used Spring email to send the emails
Spring Data repositories usually extend from the Repository or CrudRepository interfaces. If you use auto-configuration, repositories are searched from the package containing your main configuration class (the one annotated with @EnableAutoConfiguration or @SpringBootApplication) down.
Used Spring Boot caching to cache the entities in the Java memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment