- Java 17
- Intellij IDE (Integrated Development Environment)
- Docker Desktop
- Maven Build tool
- PostMan for Rest API Testing
- Git Bash
- Tortoise Git
- Database Client
start docker desktop
docker compose up
mvn clean spring-boot:run -Dspring-boot.run.profiles=redis
mvn clean spring-boot:run
mvn clean test
-
Add below Dependency
org.springframework.boot spring-boot-starter-web -
HTTP Methods
- GET
- Path Parameter
- Request Parameter
- PUT
- Request Body
- POST
- Request Body
- DELETE
- HTTP Status codes
- 200 Series
- 400 Series
- 500 Series
- Media Types : JSON , XML
- Produces
- Consumes
- GET
-
Add below Dependency and Driver
org.springframework.boot spring-boot-starter-data-jpa -
Create a model with below Annotations
- @Entity
- @Id
-
Create a Repository
@Repository public interface StudentRepository extends JpaRepository<Student, Integer> { //Code Generation Technique: DSL }
Swagger ::: https://springdoc.org/
-
Add dependencies in pom.xml
-
Add openDoc Depdency
org.springdoc springdoc-openapi-ui 1.6.13 -
Add @ Bean for DocketAPI
-
@Bean public OpenAPI customOpenAPI() { return new OpenAPI() .components(new Components()) .info(new Info().title("Training Demo Application API").description( "This is a sample Spring Boot RESTful service using springdoc-openapi and OpenAPI 3.")); }
-
open url :http://localhost:port/context-path/swagger-ui.html
-
@ Bean for Programatic Data Source
-
Embedded will be created if you add depedency
com.h2database h2 runtime -
Connection Pooling
-
use for Hikari: spring.datasource.type=com.zaxxer.hikari.HikariDataSource
-
use the below config for Datasource
spring: datasource: url: jdbc:mysql://localhost:3306/mysql username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver
- debug=false
- logging.file=application.log
- logging.level.org.springframework=INFO
- logging.level.org.org.hibernate=WARN
-
Add below Dependency in the pom.xml
org.springframework.boot spring-boot-starter-actuator -
By default all actuator endpoints can be seen : "http://serveropaddress:port/context-path/actuator"
-
By default Endpoints are disabled due to Secure data
-
enable all endpoints by : management.endpoints.web.exposure.include: "*"
-
Shutdown endpoint needs to be enabled. This will not be covered in all(*)
- @Component
- @RestController
- @RequestMapping
- @Service
- @Repository
- @SpringBootApplication
- @Bean
- @Autowired
- @Query
- @Transactional
-
HMR(Hot Module Replacement)
org.springframework.boot spring-boot-devtools runtime -
Ensures Restart of Project upon save
-
It does not detect the pom.xml changes
- Spring profiles active
- Server port
- Conext path : Different Application name
- usage of tab
-
for Multiple Properties
@Autowired Environment env;
-
for single property
@Value("property.name)
- use @ Valid wherever it needs to be validated
- @NotNull
- @Min
- @Max
- @Size
- @Past/@Future
- @Negative/@Positive
-
download JAR freom below:
https://www.oracle.com/technetwork/apps-tech/jdbc-112010-090769.html
-
Install to local repo:
mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=12.1.0.1 -Dpackaging=jar
-
Add pom dependency
com.oracle ojdbc6 12.1.0.1 -
create a user and give privilages
CREATE USER crud IDENTIFIED BY crud;
GRANT CONNECT TO crud;
GRANT CONNECT, RESOURCE, DBA TO crud;
GRANT CREATE SESSION TO crud;
GRANT UNLIMITED TABLESPACE TO crud;
-
CREATE SEQUENCE student_seq MINVALUE 1 MAXVALUE 9999999999 START WITH 4 INCREMENT BY 1;
-
Add below dependency in pom.xml
org.springframework.boot spring-boot-starter-data-mongodb -
mention connection details in .yml file or(application.properties)
spring: data: mongodb: host: localhost port: 27017 database: courses
-
create a mongo Repository
public interface CourseRepository extends MongoRepository<Course, String> {
}
- http://localhost:8090/crudapp/swagger-ui.html
- username is : admin& admin
- yet to implement documentation Tasks
- Exception Handling
- Controller Specific
- Unit Testing
- Integration Testing
- Auditing...Added Auditing
- Oauth2 Integration
- password flow
- Authorization Code
- Client Credentials
- Vault Service Integration
- Spring Cloud Config Integration
- Resilient 4J integration
- CQRS integration
- Native Queries
- JDBC and Batch Support
- Spring Cloud Sleuth support
- Spring Micrometer integration
- Dockerized this app
- K8S integration
- Making external calls to the app
- Jmeter Test cases
- API Integrations
- GraphQL
- WebFlux
- File Upload
- Web Socket
- Encryption utilities
- Base 64 encryption
- HAL Media types
- Actuator End points
- Encrypting
- Custom Logging: Specifying the logger
- Many to Many mapping
- two data sources in the same project
- Unit Test cases
- File upload and download