Spring boot project for beginner level
Server: Java, Java Spring boot, JPA, lombok,
Database: Mysql
Clone project from github
git clone [email protected]:Nathapons/spring-boot-basic-structure.git
cd spring-boot-basic-structure
Set up application.yml. If you don't have please create the file in /src/main/resources
spring:
datasource:
url: jdbc:mysql://<your-database-host>:<your-database-port>/<your-database-name>
username: <your-database-username>
password: <your-database-password>
jpa:
show-sql: true
generate-ddl: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
hibernate:
ddl-auto: update
server:
port: <your-port>
To run tests, run the following command
mvn spring-boot:run
or
mvn clean spring-boot:run
Remark: Please make sure your running at Demo1Application.java
Parameter | Type | Json | Description |
---|---|---|---|
id |
long |
id | user id |
firstName |
string |
first_name | first name of user |
lastName |
string |
last_name | last name of user |
age |
int |
age | age of user |
Parameter | Type | Json | Description |
---|---|---|---|
id |
long |
id | address id |
street |
string |
street | - |
city |
string |
city | - |
zipCode |
int |
zip_code | - |
user |
int |
user | user id which is relate with user |
GET /apis/v1/users
GET /api/user/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of user to fetch |
POST /api/users
Request body | Type | Description |
---|---|---|
first_name |
string |
Required. first name of user |
last_name |
string |
Required. last name of user |
age |
int |
Required. age of user |
PUT /api/user/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of user to fetch |
Request body | Type | Description |
---|---|---|
first_name |
string |
Required. first name of user |
last_name |
string |
Required. last name of user |
age |
int |
Required. age of user |
DELETE /api/user/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of user to fetch |
GET /apis/v1/address
GET /api/address/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of address to fetch |
POST /api/address
Request body | Type | Description |
---|---|---|
street |
string |
Required. |
city |
string |
Required. |
zip_code |
string |
Required. |
user |
int |
Required. user id of user entity |
PUT /api/address/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of address to fetch |
Request body | Type | Description |
---|---|---|
street |
string |
Required. |
city |
string |
Required. |
zip_code |
string |
Required. |
user |
int |
Required. user id of user entity |
DELETE /api/address/{id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of address to fetch |