- Run the
CustomerapiApplication
Application - Default application runs on the port 8080 and url to access application http://localhost:8080
- This app also embedded with the actuator, by default has health check endpoint
/health
- When there are any port errors in the console, override the port by setting the
server.port=808x
(where x is any number) in theapplication.properties
- Application comes with H2 in memory database.
- Quick Start on H2 Database
- URL to access the H2 DB Admin console
- Enter
JDBC URL
asjdbc:h2:mem:testdb
- To run the application with Microsoft SQL Server
-
Add the dependency in
build.gradle
fileimplementation 'com.microsoft.sqlserver:mssql-jdbc'
-
Add the below configuration in
application.properties
spring.jpa.properties.hibernate.format_sql=true spring.datasource.url= jdbc:sqlserver://localhost:1433;encrypt=true;trustServerCertificate=true;databaseName=sqlserver_db spring.datasource.username= sqlserver spring.datasource.password= admin spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.SQLServerDialect spring.jpa.hibernate.ddl-auto= update
-
- Postman collection is available at location
src\test\newman
- Here is the reference link to import the postman collection
- Once the Postman collection is imported, it will contain all the customer operations.
- GET is to SELECT SQL operation
- Get all the list of Customers
GET http://localhost:8080/api/customers
- Get a customer with id
http://localhost:8080/api/customers/{id}
- Get all the list of Customers
- POST is INSERT SQL Operation
- Add customer
POST http://localhost:8080/api/customers
. Customers details will be send in the RequestBody.
- Add customer
- PUT is to UPDATE SQL Operation
- Update Customer
PUT http://localhost:8080/api/customers/{id}
Customers details will be send in the RequestBody.
- Update Customer
- DELETE is to DELETE SQL Operation
- Delete Customer
DELETE http://localhost:8080/api/customers/{id}
- Delete Customer
- GET is to SELECT SQL operation
For further reference, please consider the following sections:
- Official Gradle documentation
- Spring Boot Gradle Plugin Reference Guide
- Create an OCI image
- Spring Web
- Spring Data JPA
The following guides illustrate how to use some features concretely:
- Building a RESTful Web Service
- Serving Web Content with Spring MVC
- Building REST services with Spring
- Accessing Data with JPA
These additional references should also help you: