Skip to content

Commit c73e743

Browse files
committed
Fix redis connection issue
1 parent 444b219 commit c73e743

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

app/src/main/java/com/example/app/Peanuts.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Peanuts implements Serializable {
1414

1515
@Id
1616
@GeneratedValue(strategy = GenerationType.IDENTITY)
17+
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
1718
private Long id;
1819

1920
@Schema(example = "Snoopy")

app/src/main/java/com/example/app/PeanutsService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.cache.annotation.CachePut;
55
import org.springframework.cache.annotation.Cacheable;
66
import org.springframework.stereotype.Service;
7+
import org.springframework.transaction.annotation.Transactional;
78

89
@Service
910
public class PeanutsService {

app/src/main/resources/application-test.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ spring:
88
ddl-auto: update
99
cache:
1010
type: redis
11-
redis:
12-
host: localhost
13-
port: 6379
11+
# https://stackoverflow.com/a/79180709
12+
data:
13+
redis:
14+
host: localhost
15+
port: 6379

app/src/main/resources/application.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ spring:
2727
ddl-auto: update
2828
cache:
2929
type: redis
30-
redis:
31-
host: redis
32-
port: 6379
30+
# https://stackoverflow.com/a/79180709
31+
data:
32+
redis:
33+
host: redis
34+
port: 6379

docker-compose.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ x-app-dependencies: &app-dependencies
1515
postgres:
1616
condition: service_healthy
1717
redis:
18-
condition: service_started
18+
condition: service_healthy
1919

2020
services:
2121
# Infrastructure
@@ -136,3 +136,8 @@ services:
136136
ports:
137137
- "6379:6379"
138138
logging: *default-logging
139+
healthcheck:
140+
test: ["CMD", "redis-cli", "ping"]
141+
interval: 5s
142+
timeout: 3s
143+
retries: 5

0 commit comments

Comments
 (0)