1
-
2
1
# Spring Boot application with Redis in persistence layer
2
+
3
3
[ ![ Java CI with Maven] ( https://github.com/andrei-punko/spring-boot-redis/actions/workflows/maven.yml/badge.svg )] ( https://github.com/andrei-punko/spring-boot-redis/actions/workflows/maven.yml )
4
4
[ ![ Coverage] ( .github/badges/jacoco.svg )] ( https://github.com/andrei-punko/spring-boot-redis/actions/workflows/maven.yml )
5
5
[ ![ Branches] ( .github/badges/branches.svg )] ( https://github.com/andrei-punko/spring-boot-redis/actions/workflows/maven.yml )
@@ -10,76 +10,93 @@ Includes web-server on port 9080 with `/api/v1/articles` endpoint exposed.
10
10
Supports CRUD set of operations and R with pagination
11
11
12
12
## Prerequisites:
13
+
13
14
- Maven 3
14
15
- JDK 21
15
16
16
17
## How to build:
18
+
17
19
``` shell
18
20
mvn clean install
19
21
```
20
22
21
23
### Build Docker image with application inside:
24
+
22
25
``` shell
23
26
docker build --no-cache ./ -t spring-boot-redis-app
24
27
```
25
28
26
29
## Start application using starting script:
30
+
27
31
Use [ run-in-docker.bat] ( run-in-docker.bat ) script
28
32
29
33
## Start application by running executable jar (Redis should be started before that manually):
34
+
30
35
java -jar target/spring-boot-redis-0.0.1-SNAPSHOT.jar \
31
36
--spring.redis.host=localhost \
32
37
--spring.redis.port=6379
33
38
34
39
## Same thing but using Spring profile to determine properties (Redis should be started before that manually):
40
+
35
41
java -jar target/spring-boot-redis-0.0.1-SNAPSHOT.jar \
36
42
--spring.profiles.active=dev
37
43
38
44
## Start application using Maven (Redis should be started before that manually):
45
+
39
46
mvn spring-boot:run -Dspring-boot.run.arguments="\
40
47
--spring.redis.host=localhost \
41
48
--spring.redis.port=6379
42
49
43
50
## Same thing but using Spring profile to determine properties (Redis should be started before that manually):
51
+
44
52
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.profiles.active=dev
45
53
46
54
## Start application using set of two Docker containers - one with Redis and another with application:
55
+
47
56
docker-compose up
48
57
49
- ## Link for quick check:
58
+ ## Link for quick check:
59
+
50
60
http://localhost:9080/api/v1/articles
51
61
52
- ## Swagger documentation:
62
+ ## Swagger documentation:
63
+
53
64
http://localhost:9080/swagger-ui/index.html
54
65
55
66
## Useful CURL commands:
56
67
57
- ### New article addition:
68
+ ### New article addition:
69
+
58
70
``` shell
59
71
curl -i -H " Accept: application/json" -H " Content-Type: application/json" -d ' { "title": "Some tittle", "text": "Some text", "summary": "bla-bla", "author": "Pushkin" }' -X POST http://localhost:9080/api/v1/articles
60
72
```
61
73
62
- ### Get existing article:
74
+ ### Get existing article:
75
+
63
76
``` shell
64
77
curl -i http://localhost:9080/api/v1/articles/1
65
78
```
66
79
67
- ### Update existing article:
80
+ ### Update existing article:
81
+
68
82
``` shell
69
83
curl -i -H " Accept: application/json" -H " Content-Type: application/json" -d ' { "title": "Another tittle" }' -X PATCH http://localhost:9080/api/v1/articles/2
70
84
```
71
85
72
86
### Get all articles:
87
+
73
88
``` shell
74
89
curl -i http://localhost:9080/api/v1/articles
75
90
```
76
91
77
- ### Get list of articles with pagination support:
92
+ ### Get list of articles with pagination support:
93
+
78
94
``` shell
79
95
curl -i ' http://localhost:9080/api/v1/articles?size=2&page=4&sort=author.firstName,DESC'
80
96
```
81
97
82
- ### Deletion of article:
98
+ ### Deletion of article:
99
+
83
100
``` shell
84
101
curl -i -X DELETE http://localhost:9080/api/v1/articles/1
85
102
```
0 commit comments