You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+35-8Lines changed: 35 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Project Overview
4
4
5
-
This is a RESTful Web Service proof-of-concept built with **Spring Boot 4** targeting **JDK 25 (LTS)**. The application demonstrates a clean, layered architecture implementing a CRUD API for managing books. It uses an in-memory H2 database for data persistence and includes comprehensive test coverage.
5
+
This is a RESTful Web Service proof-of-concept built with **Spring Boot 4** targeting **JDK 25 (LTS)**. The application demonstrates a clean, layered architecture implementing a CRUD API for managing books. It uses a **SQLite database** for runtime persistence (with a pre-seeded database in Docker) and **H2 in-memory** for fast test execution.
6
6
7
7
**Key URLs:**
8
8
@@ -17,7 +17,7 @@ This is a RESTful Web Service proof-of-concept built with **Spring Boot 4** targ
17
17
-**Java**: JDK 25 (LTS) - use modern Java features where appropriate
18
18
-**Spring Boot**: 4.0.0 with modular starter dependencies (WebMVC, Data JPA, Validation, Cache, Actuator)
19
19
-**Build Tool**: Maven 3.9+ (use `./mvnw` wrapper, NOT system Maven)
The Docker container uses a "hold" pattern for the pre-seeded SQLite database:
178
+
179
+
1. Build stage copies `storage/books-sqlite3.db` to `/app/hold/` in the image
180
+
2. On first container run, `entrypoint.sh` copies the database to `/storage/` volume
181
+
3. Subsequent runs use the existing database from the volume
182
+
4. To reset: `docker compose down -v` removes volumes, next `up` restores seed data
183
+
167
184
## Common Tasks & Patterns
168
185
169
186
### Adding a New REST Endpoint
@@ -203,15 +220,18 @@ docker compose logs -f
203
220
### Build Failures
204
221
205
222
-**Lombok not working**: Ensure annotation processor is enabled in IDE and `maven-compiler-plugin` includes Lombok path
206
-
-**Tests failing**: Check if H2 database is properly initialized; review `BooksDataInitializer.seed()`
223
+
-**Tests failing**: Tests use H2 in-memory database via `src/test/resources/application.properties`
207
224
-**Port already in use**: Change `server.port` in `application.properties` or kill process using ports 9000/9001
208
225
-**JAVA_HOME not set**: Run `export JAVA_HOME=$(/usr/libexec/java_home -v 25)` on macOS or set to JDK 25 path on other systems
209
226
-**CacheManager errors in tests**: Add `@AutoConfigureCache` annotation to slice tests (`@WebMvcTest`, `@DataJpaTest`)
227
+
-**SQLite file not found**: Ensure `storage/books-sqlite3.db` exists for local development
210
228
211
229
### Docker Issues
212
230
213
231
-**Container health check failing**: Verify Actuator is accessible at `http://localhost:9001/actuator/health`
214
232
-**Build context too large**: Ensure `.dockerignore` excludes `target/` and `.git/`
233
+
-**Database not persisting**: Check that `java-samples-spring-boot_storage` volume exists (`docker volume ls`)
234
+
-**Stale seed data**: Run `docker compose down -v` to remove volumes and restore fresh seed data on next `up`
215
235
216
236
### Common Pitfalls
217
237
@@ -221,6 +241,13 @@ docker compose logs -f
221
241
-**Repository interfaces**: Custom query methods may not show in coverage (JaCoCo limitation)
222
242
-**Spring Boot 4.0 modular packages**: Test annotations like `@WebMvcTest`, `@DataJpaTest`, and `@AutoConfigureCache` are now in modular packages (e.g., `org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest`)
223
243
244
+
### SQLite Configuration Notes
245
+
246
+
-**Date storage**: LocalDate fields are stored as Unix timestamps (INTEGER) for robustness - no parsing issues
- ✅ **CI/CD Ready** - GitHub Actions with automated testing and container builds
52
52
53
53
## Architecture
@@ -130,6 +130,17 @@ docker compose down
130
130
-`9000` - Main API server
131
131
-`9001` - Actuator management endpoints
132
132
133
+
**Persistent Storage:**
134
+
135
+
The Docker container uses a pre-seeded SQLite database with sample book data. On first run, the database is copied from the image to a named volume (`java-samples-spring-boot_storage`) ensuring data persistence across container restarts.
136
+
137
+
To reset the database to its initial state:
138
+
139
+
```bash
140
+
docker compose down -v # Remove volumes
141
+
docker compose up # Fresh start with seed data
142
+
```
143
+
133
144
## API Reference
134
145
135
146
The Books API provides standard CRUD operations:
@@ -180,6 +191,7 @@ open target/site/jacoco/index.html
180
191
**Test Structure:**
181
192
182
193
-**Unit Tests** - `@WebMvcTest`, `@DataJpaTest` for isolated layer testing (with `@AutoConfigureCache` for caching support)
194
+
-**Test Database** - H2 in-memory database for fast, isolated test execution
183
195
-**Mocking** - Mockito with `@MockitoBean` for dependency mocking
0 commit comments