- https://youtu.be/9SGDpanrc8U
- JUnit: https://youtu.be/Geq60OVyBPg?t=1479
- assertj: https://www.baeldung.com/introduction-to-assertj
PostgreSQL config
spring:
datasource:
url: jdbc:postgresql://localhost:5432/student
username:
password:
jpa:
hibernate:
ddl-auto: 'create-drop'
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
MySql config
spring:
datasource:
url: jdbc:mysql://localhost:3306/student
username: root
password: root1234
jpa:
hibernate:
ddl-auto: 'create-drop'
show-sql: true
Also, replace postgresql dependency with mysql dependency when changing the database
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
Create:
curl --location --request POST 'localhost:8080/api/v1/student/' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Joe Goldberg",
"email": "joeg@gmail.com",
"age": 25,
"dob": "2001-06-20"
}'
Get:
curl --location --request GET 'localhost:8080/api/v1/student/'
curl --location --request GET 'localhost:8080/api/v1/student/1'
Update:
curl --location --request PUT 'localhost:8080/api/v1/student/2?name=Joe&email=joeg2@gmail.com' \
--header 'Content-Type: application/json' \
--data-raw ''
Delete:
curl --location --request DELETE 'localhost:8080/api/v1/student/1' \
--data-raw ''
cd target
java -jar demo-0.0.1-SNAPSHOT.jar
on default port 8080
java -jar demo-0.0.1-SNAPSHOT.jar --server.port=8081
java -jar demo-0.0.1-SNAPSHOT.jar --server.port=8082
Synchronous client to perform HTTP requests, exposing a simple, template method API over underlying HTTP client libraries such as the JDK HttpURLConnection, Apache HttpComponents, and others.
- https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html
- https://howtodoinjava.com/spring-boot2/resttemplate/spring-restful-client-resttemplate-example/
- https://www.baeldung.com/rest-template
Non-blocking, reactive client to perform HTTP requests, exposing a fluent, reactive API over underlying HTTP client libraries such as Reactor Netty.