@brookmind/ai-toolkit 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
# Spring Boot Development Skill
|
|
2
|
+
|
|
3
|
+
A comprehensive skill for building modern Spring Boot applications with REST APIs, database integration, security, and enterprise Java patterns.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Spring Boot is an opinionated framework built on top of the Spring Framework that makes it easy to create stand-alone, production-grade Spring-based applications. It provides auto-configuration, embedded servers, and production-ready features out of the box.
|
|
8
|
+
|
|
9
|
+
### Key Features
|
|
10
|
+
|
|
11
|
+
- **Auto-Configuration**: Automatically configures Spring application based on dependencies
|
|
12
|
+
- **Embedded Servers**: Built-in Tomcat, Jetty, or Undertow - no need for WAR deployment
|
|
13
|
+
- **Production-Ready**: Actuator endpoints for monitoring, health checks, and metrics
|
|
14
|
+
- **Starter Dependencies**: Curated sets of dependencies for different use cases
|
|
15
|
+
- **Convention over Configuration**: Sensible defaults with minimal configuration
|
|
16
|
+
- **Spring Ecosystem**: Full access to Spring Framework, Spring Data, Spring Security, etc.
|
|
17
|
+
|
|
18
|
+
## Getting Started
|
|
19
|
+
|
|
20
|
+
### Prerequisites
|
|
21
|
+
|
|
22
|
+
- Java 17 or higher
|
|
23
|
+
- Maven 3.6+ or Gradle 7+
|
|
24
|
+
- IDE (IntelliJ IDEA, Eclipse, VS Code)
|
|
25
|
+
- Database (PostgreSQL, MySQL, H2, etc.)
|
|
26
|
+
|
|
27
|
+
### Create a New Spring Boot Project
|
|
28
|
+
|
|
29
|
+
**Using Spring Initializr (https://start.spring.io/):**
|
|
30
|
+
|
|
31
|
+
1. Project: Maven or Gradle
|
|
32
|
+
2. Language: Java
|
|
33
|
+
3. Spring Boot: 3.x (latest stable)
|
|
34
|
+
4. Project Metadata:
|
|
35
|
+
- Group: com.example
|
|
36
|
+
- Artifact: myapp
|
|
37
|
+
- Package name: com.example.myapp
|
|
38
|
+
- Packaging: Jar
|
|
39
|
+
- Java: 17
|
|
40
|
+
|
|
41
|
+
5. Dependencies:
|
|
42
|
+
- Spring Web
|
|
43
|
+
- Spring Data JPA
|
|
44
|
+
- PostgreSQL Driver (or your database)
|
|
45
|
+
- Spring Security
|
|
46
|
+
- Validation
|
|
47
|
+
- Lombok (optional)
|
|
48
|
+
|
|
49
|
+
**Using Maven:**
|
|
50
|
+
|
|
51
|
+
```xml
|
|
52
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
53
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
54
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
55
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
56
|
+
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
57
|
+
<modelVersion>4.0.0</modelVersion>
|
|
58
|
+
|
|
59
|
+
<parent>
|
|
60
|
+
<groupId>org.springframework.boot</groupId>
|
|
61
|
+
<artifactId>spring-boot-starter-parent</artifactId>
|
|
62
|
+
<version>3.2.0</version>
|
|
63
|
+
<relativePath/>
|
|
64
|
+
</parent>
|
|
65
|
+
|
|
66
|
+
<groupId>com.example</groupId>
|
|
67
|
+
<artifactId>myapp</artifactId>
|
|
68
|
+
<version>0.0.1-SNAPSHOT</version>
|
|
69
|
+
<name>myapp</name>
|
|
70
|
+
<description>My Spring Boot Application</description>
|
|
71
|
+
|
|
72
|
+
<properties>
|
|
73
|
+
<java.version>17</java.version>
|
|
74
|
+
</properties>
|
|
75
|
+
|
|
76
|
+
<dependencies>
|
|
77
|
+
<!-- Spring Boot Web -->
|
|
78
|
+
<dependency>
|
|
79
|
+
<groupId>org.springframework.boot</groupId>
|
|
80
|
+
<artifactId>spring-boot-starter-web</artifactId>
|
|
81
|
+
</dependency>
|
|
82
|
+
|
|
83
|
+
<!-- Spring Data JPA -->
|
|
84
|
+
<dependency>
|
|
85
|
+
<groupId>org.springframework.boot</groupId>
|
|
86
|
+
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
|
87
|
+
</dependency>
|
|
88
|
+
|
|
89
|
+
<!-- PostgreSQL Driver -->
|
|
90
|
+
<dependency>
|
|
91
|
+
<groupId>org.postgresql</groupId>
|
|
92
|
+
<artifactId>postgresql</artifactId>
|
|
93
|
+
<scope>runtime</scope>
|
|
94
|
+
</dependency>
|
|
95
|
+
|
|
96
|
+
<!-- Spring Security -->
|
|
97
|
+
<dependency>
|
|
98
|
+
<groupId>org.springframework.boot</groupId>
|
|
99
|
+
<artifactId>spring-boot-starter-security</artifactId>
|
|
100
|
+
</dependency>
|
|
101
|
+
|
|
102
|
+
<!-- Validation -->
|
|
103
|
+
<dependency>
|
|
104
|
+
<groupId>org.springframework.boot</groupId>
|
|
105
|
+
<artifactId>spring-boot-starter-validation</artifactId>
|
|
106
|
+
</dependency>
|
|
107
|
+
|
|
108
|
+
<!-- Actuator -->
|
|
109
|
+
<dependency>
|
|
110
|
+
<groupId>org.springframework.boot</groupId>
|
|
111
|
+
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
112
|
+
</dependency>
|
|
113
|
+
|
|
114
|
+
<!-- Testing -->
|
|
115
|
+
<dependency>
|
|
116
|
+
<groupId>org.springframework.boot</groupId>
|
|
117
|
+
<artifactId>spring-boot-starter-test</artifactId>
|
|
118
|
+
<scope>test</scope>
|
|
119
|
+
</dependency>
|
|
120
|
+
|
|
121
|
+
<dependency>
|
|
122
|
+
<groupId>org.springframework.security</groupId>
|
|
123
|
+
<artifactId>spring-security-test</artifactId>
|
|
124
|
+
<scope>test</scope>
|
|
125
|
+
</dependency>
|
|
126
|
+
</dependencies>
|
|
127
|
+
|
|
128
|
+
<build>
|
|
129
|
+
<plugins>
|
|
130
|
+
<plugin>
|
|
131
|
+
<groupId>org.springframework.boot</groupId>
|
|
132
|
+
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
133
|
+
</plugin>
|
|
134
|
+
</plugins>
|
|
135
|
+
</build>
|
|
136
|
+
</project>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Project Structure
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
myapp/
|
|
143
|
+
├── src/
|
|
144
|
+
│ ├── main/
|
|
145
|
+
│ │ ├── java/
|
|
146
|
+
│ │ │ └── com/
|
|
147
|
+
│ │ │ └── example/
|
|
148
|
+
│ │ │ └── myapp/
|
|
149
|
+
│ │ │ ├── MyAppApplication.java
|
|
150
|
+
│ │ │ ├── config/
|
|
151
|
+
│ │ │ │ ├── SecurityConfig.java
|
|
152
|
+
│ │ │ │ └── AppConfig.java
|
|
153
|
+
│ │ │ ├── controller/
|
|
154
|
+
│ │ │ │ └── UserController.java
|
|
155
|
+
│ │ │ ├── service/
|
|
156
|
+
│ │ │ │ └── UserService.java
|
|
157
|
+
│ │ │ ├── repository/
|
|
158
|
+
│ │ │ │ └── UserRepository.java
|
|
159
|
+
│ │ │ ├── model/
|
|
160
|
+
│ │ │ │ └── User.java
|
|
161
|
+
│ │ │ ├── dto/
|
|
162
|
+
│ │ │ │ └── UserDTO.java
|
|
163
|
+
│ │ │ └── exception/
|
|
164
|
+
│ │ │ ├── ResourceNotFoundException.java
|
|
165
|
+
│ │ │ └── GlobalExceptionHandler.java
|
|
166
|
+
│ │ └── resources/
|
|
167
|
+
│ │ ├── application.yml
|
|
168
|
+
│ │ ├── application-dev.yml
|
|
169
|
+
│ │ ├── application-prod.yml
|
|
170
|
+
│ │ └── db/
|
|
171
|
+
│ │ └── migration/
|
|
172
|
+
│ │ └── V1__Create_users_table.sql
|
|
173
|
+
│ └── test/
|
|
174
|
+
│ └── java/
|
|
175
|
+
│ └── com/
|
|
176
|
+
│ └── example/
|
|
177
|
+
│ └── myapp/
|
|
178
|
+
│ ├── MyAppApplicationTests.java
|
|
179
|
+
│ ├── controller/
|
|
180
|
+
│ │ └── UserControllerTest.java
|
|
181
|
+
│ └── service/
|
|
182
|
+
│ └── UserServiceTest.java
|
|
183
|
+
├── pom.xml
|
|
184
|
+
└── README.md
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Basic Application Setup
|
|
188
|
+
|
|
189
|
+
**Main Application Class:**
|
|
190
|
+
|
|
191
|
+
```java
|
|
192
|
+
package com.example.myapp;
|
|
193
|
+
|
|
194
|
+
import org.springframework.boot.SpringApplication;
|
|
195
|
+
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
196
|
+
|
|
197
|
+
@SpringBootApplication
|
|
198
|
+
public class MyAppApplication {
|
|
199
|
+
|
|
200
|
+
public static void main(String[] args) {
|
|
201
|
+
SpringApplication.run(MyAppApplication.class, args);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Configuration (application.yml):**
|
|
207
|
+
|
|
208
|
+
```yaml
|
|
209
|
+
spring:
|
|
210
|
+
application:
|
|
211
|
+
name: myapp
|
|
212
|
+
|
|
213
|
+
datasource:
|
|
214
|
+
url: jdbc:postgresql://localhost:5432/mydb
|
|
215
|
+
username: postgres
|
|
216
|
+
password: password
|
|
217
|
+
driver-class-name: org.postgresql.Driver
|
|
218
|
+
|
|
219
|
+
jpa:
|
|
220
|
+
hibernate:
|
|
221
|
+
ddl-auto: validate
|
|
222
|
+
show-sql: true
|
|
223
|
+
properties:
|
|
224
|
+
hibernate:
|
|
225
|
+
dialect: org.hibernate.dialect.PostgreSQLDialect
|
|
226
|
+
format_sql: true
|
|
227
|
+
|
|
228
|
+
security:
|
|
229
|
+
user:
|
|
230
|
+
name: admin
|
|
231
|
+
password: admin
|
|
232
|
+
|
|
233
|
+
server:
|
|
234
|
+
port: 8080
|
|
235
|
+
servlet:
|
|
236
|
+
context-path: /api
|
|
237
|
+
|
|
238
|
+
logging:
|
|
239
|
+
level:
|
|
240
|
+
root: INFO
|
|
241
|
+
com.example.myapp: DEBUG
|
|
242
|
+
|
|
243
|
+
management:
|
|
244
|
+
endpoints:
|
|
245
|
+
web:
|
|
246
|
+
exposure:
|
|
247
|
+
include: health,info,metrics
|
|
248
|
+
endpoint:
|
|
249
|
+
health:
|
|
250
|
+
show-details: always
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Running the Application
|
|
254
|
+
|
|
255
|
+
**Using Maven:**
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# Run the application
|
|
259
|
+
./mvnw spring-boot:run
|
|
260
|
+
|
|
261
|
+
# Run with specific profile
|
|
262
|
+
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev
|
|
263
|
+
|
|
264
|
+
# Build and run jar
|
|
265
|
+
./mvnw clean package
|
|
266
|
+
java -jar target/myapp-0.0.1-SNAPSHOT.jar
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Using Gradle:**
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Run the application
|
|
273
|
+
./gradlew bootRun
|
|
274
|
+
|
|
275
|
+
# Build and run jar
|
|
276
|
+
./gradlew build
|
|
277
|
+
java -jar build/libs/myapp-0.0.1-SNAPSHOT.jar
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Using IDE:**
|
|
281
|
+
|
|
282
|
+
Run the main application class (`MyAppApplication.java`) directly from your IDE.
|
|
283
|
+
|
|
284
|
+
## Quick Start Examples
|
|
285
|
+
|
|
286
|
+
### 1. Simple REST Controller
|
|
287
|
+
|
|
288
|
+
```java
|
|
289
|
+
@RestController
|
|
290
|
+
@RequestMapping("/api/hello")
|
|
291
|
+
public class HelloController {
|
|
292
|
+
|
|
293
|
+
@GetMapping
|
|
294
|
+
public String sayHello() {
|
|
295
|
+
return "Hello, Spring Boot!";
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
@GetMapping("/{name}")
|
|
299
|
+
public String sayHelloToName(@PathVariable String name) {
|
|
300
|
+
return "Hello, " + name + "!";
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Test: `curl http://localhost:8080/api/hello/World`
|
|
306
|
+
|
|
307
|
+
### 2. Entity and Repository
|
|
308
|
+
|
|
309
|
+
```java
|
|
310
|
+
@Entity
|
|
311
|
+
@Table(name = "users")
|
|
312
|
+
public class User {
|
|
313
|
+
@Id
|
|
314
|
+
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
315
|
+
private Long id;
|
|
316
|
+
|
|
317
|
+
private String name;
|
|
318
|
+
private String email;
|
|
319
|
+
|
|
320
|
+
// Getters and setters
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
@Repository
|
|
324
|
+
public interface UserRepository extends JpaRepository<User, Long> {
|
|
325
|
+
Optional<User> findByEmail(String email);
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### 3. Service Layer
|
|
330
|
+
|
|
331
|
+
```java
|
|
332
|
+
@Service
|
|
333
|
+
public class UserService {
|
|
334
|
+
|
|
335
|
+
private final UserRepository userRepository;
|
|
336
|
+
|
|
337
|
+
public UserService(UserRepository userRepository) {
|
|
338
|
+
this.userRepository = userRepository;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
public List<User> findAll() {
|
|
342
|
+
return userRepository.findAll();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
public Optional<User> findById(Long id) {
|
|
346
|
+
return userRepository.findById(id);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
public User save(User user) {
|
|
350
|
+
return userRepository.save(user);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### 4. Complete CRUD Controller
|
|
356
|
+
|
|
357
|
+
```java
|
|
358
|
+
@RestController
|
|
359
|
+
@RequestMapping("/api/users")
|
|
360
|
+
public class UserController {
|
|
361
|
+
|
|
362
|
+
private final UserService userService;
|
|
363
|
+
|
|
364
|
+
public UserController(UserService userService) {
|
|
365
|
+
this.userService = userService;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
@GetMapping
|
|
369
|
+
public List<User> getAllUsers() {
|
|
370
|
+
return userService.findAll();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
@GetMapping("/{id}")
|
|
374
|
+
public ResponseEntity<User> getUserById(@PathVariable Long id) {
|
|
375
|
+
return userService.findById(id)
|
|
376
|
+
.map(ResponseEntity::ok)
|
|
377
|
+
.orElse(ResponseEntity.notFound().build());
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
@PostMapping
|
|
381
|
+
public ResponseEntity<User> createUser(@Valid @RequestBody User user) {
|
|
382
|
+
User created = userService.save(user);
|
|
383
|
+
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
@PutMapping("/{id}")
|
|
387
|
+
public ResponseEntity<User> updateUser(@PathVariable Long id,
|
|
388
|
+
@Valid @RequestBody User user) {
|
|
389
|
+
return userService.findById(id)
|
|
390
|
+
.map(existing -> {
|
|
391
|
+
user.setId(id);
|
|
392
|
+
return ResponseEntity.ok(userService.save(user));
|
|
393
|
+
})
|
|
394
|
+
.orElse(ResponseEntity.notFound().build());
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
@DeleteMapping("/{id}")
|
|
398
|
+
public ResponseEntity<Void> deleteUser(@PathVariable Long id) {
|
|
399
|
+
if (userService.findById(id).isPresent()) {
|
|
400
|
+
userService.delete(id);
|
|
401
|
+
return ResponseEntity.noContent().build();
|
|
402
|
+
}
|
|
403
|
+
return ResponseEntity.notFound().build();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## Common Development Tasks
|
|
409
|
+
|
|
410
|
+
### Database Setup
|
|
411
|
+
|
|
412
|
+
**H2 In-Memory Database (for development):**
|
|
413
|
+
|
|
414
|
+
```yaml
|
|
415
|
+
spring:
|
|
416
|
+
datasource:
|
|
417
|
+
url: jdbc:h2:mem:testdb
|
|
418
|
+
driver-class-name: org.h2.Driver
|
|
419
|
+
h2:
|
|
420
|
+
console:
|
|
421
|
+
enabled: true
|
|
422
|
+
path: /h2-console
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**PostgreSQL:**
|
|
426
|
+
|
|
427
|
+
```yaml
|
|
428
|
+
spring:
|
|
429
|
+
datasource:
|
|
430
|
+
url: jdbc:postgresql://localhost:5432/mydb
|
|
431
|
+
username: postgres
|
|
432
|
+
password: password
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**MySQL:**
|
|
436
|
+
|
|
437
|
+
```yaml
|
|
438
|
+
spring:
|
|
439
|
+
datasource:
|
|
440
|
+
url: jdbc:mysql://localhost:3306/mydb
|
|
441
|
+
username: root
|
|
442
|
+
password: password
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### Database Migrations
|
|
446
|
+
|
|
447
|
+
**Using Flyway:**
|
|
448
|
+
|
|
449
|
+
Add dependency:
|
|
450
|
+
```xml
|
|
451
|
+
<dependency>
|
|
452
|
+
<groupId>org.flywaydb</groupId>
|
|
453
|
+
<artifactId>flyway-core</artifactId>
|
|
454
|
+
</dependency>
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Create migration: `src/main/resources/db/migration/V1__Create_users_table.sql`
|
|
458
|
+
|
|
459
|
+
```sql
|
|
460
|
+
CREATE TABLE users (
|
|
461
|
+
id BIGSERIAL PRIMARY KEY,
|
|
462
|
+
name VARCHAR(255) NOT NULL,
|
|
463
|
+
email VARCHAR(255) NOT NULL UNIQUE,
|
|
464
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
465
|
+
);
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Testing
|
|
469
|
+
|
|
470
|
+
**Unit Test:**
|
|
471
|
+
|
|
472
|
+
```java
|
|
473
|
+
@SpringBootTest
|
|
474
|
+
class UserServiceTest {
|
|
475
|
+
|
|
476
|
+
@Mock
|
|
477
|
+
private UserRepository userRepository;
|
|
478
|
+
|
|
479
|
+
@InjectMocks
|
|
480
|
+
private UserService userService;
|
|
481
|
+
|
|
482
|
+
@Test
|
|
483
|
+
void testFindById() {
|
|
484
|
+
User user = new User();
|
|
485
|
+
user.setId(1L);
|
|
486
|
+
user.setName("John");
|
|
487
|
+
|
|
488
|
+
when(userRepository.findById(1L)).thenReturn(Optional.of(user));
|
|
489
|
+
|
|
490
|
+
Optional<User> result = userService.findById(1L);
|
|
491
|
+
|
|
492
|
+
assertTrue(result.isPresent());
|
|
493
|
+
assertEquals("John", result.get().getName());
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
**Integration Test:**
|
|
499
|
+
|
|
500
|
+
```java
|
|
501
|
+
@SpringBootTest
|
|
502
|
+
@AutoConfigureMockMvc
|
|
503
|
+
class UserControllerTest {
|
|
504
|
+
|
|
505
|
+
@Autowired
|
|
506
|
+
private MockMvc mockMvc;
|
|
507
|
+
|
|
508
|
+
@Test
|
|
509
|
+
void testGetUser() throws Exception {
|
|
510
|
+
mockMvc.perform(get("/api/users/1"))
|
|
511
|
+
.andExpect(status().isOk())
|
|
512
|
+
.andExpect(jsonPath("$.id").value(1));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
## Key Concepts to Master
|
|
518
|
+
|
|
519
|
+
1. **Auto-Configuration**: Understanding how Spring Boot automatically configures your application
|
|
520
|
+
2. **Dependency Injection**: Constructor injection, component scanning, bean lifecycle
|
|
521
|
+
3. **REST APIs**: Building RESTful services with proper HTTP methods and status codes
|
|
522
|
+
4. **Data Access**: JPA entities, repositories, relationships, queries
|
|
523
|
+
5. **Security**: Authentication, authorization, JWT, OAuth2
|
|
524
|
+
6. **Exception Handling**: Global exception handlers, custom exceptions
|
|
525
|
+
7. **Validation**: Bean validation, custom validators
|
|
526
|
+
8. **Testing**: Unit tests, integration tests, test slices
|
|
527
|
+
9. **Configuration**: Properties, profiles, externalized configuration
|
|
528
|
+
10. **Production**: Actuator, monitoring, logging, deployment
|
|
529
|
+
|
|
530
|
+
## Resources
|
|
531
|
+
|
|
532
|
+
- [Spring Boot Documentation](https://docs.spring.io/spring-boot/docs/current/reference/html/)
|
|
533
|
+
- [Spring Guides](https://spring.io/guides)
|
|
534
|
+
- [Baeldung Spring Boot Tutorials](https://www.baeldung.com/spring-boot)
|
|
535
|
+
- [Spring Boot GitHub](https://github.com/spring-projects/spring-boot)
|
|
536
|
+
|
|
537
|
+
## Next Steps
|
|
538
|
+
|
|
539
|
+
1. Review the SKILL.md file for comprehensive documentation
|
|
540
|
+
2. Check EXAMPLES.md for detailed code examples
|
|
541
|
+
3. Build a simple REST API project
|
|
542
|
+
4. Add database integration with Spring Data JPA
|
|
543
|
+
5. Implement authentication with Spring Security
|
|
544
|
+
6. Add validation and exception handling
|
|
545
|
+
7. Write unit and integration tests
|
|
546
|
+
8. Deploy your application
|
|
547
|
+
|
|
548
|
+
## Common Annotations Quick Reference
|
|
549
|
+
|
|
550
|
+
| Annotation | Purpose |
|
|
551
|
+
|------------|---------|
|
|
552
|
+
| `@SpringBootApplication` | Main application class |
|
|
553
|
+
| `@RestController` | REST API controller |
|
|
554
|
+
| `@Service` | Service layer component |
|
|
555
|
+
| `@Repository` | Data access layer component |
|
|
556
|
+
| `@Entity` | JPA entity |
|
|
557
|
+
| `@GetMapping` | HTTP GET request handler |
|
|
558
|
+
| `@PostMapping` | HTTP POST request handler |
|
|
559
|
+
| `@PutMapping` | HTTP PUT request handler |
|
|
560
|
+
| `@DeleteMapping` | HTTP DELETE request handler |
|
|
561
|
+
| `@PathVariable` | Extract path variable |
|
|
562
|
+
| `@RequestParam` | Extract query parameter |
|
|
563
|
+
| `@RequestBody` | Extract request body |
|
|
564
|
+
| `@Valid` | Enable validation |
|
|
565
|
+
| `@Transactional` | Enable transaction management |
|
|
566
|
+
|
|
567
|
+
## Troubleshooting
|
|
568
|
+
|
|
569
|
+
### Application won't start
|
|
570
|
+
|
|
571
|
+
- Check if port 8080 is already in use
|
|
572
|
+
- Verify database connection settings
|
|
573
|
+
- Check for missing dependencies
|
|
574
|
+
- Review application logs
|
|
575
|
+
|
|
576
|
+
### Database connection fails
|
|
577
|
+
|
|
578
|
+
- Verify database is running
|
|
579
|
+
- Check credentials in application.yml
|
|
580
|
+
- Ensure database driver dependency is included
|
|
581
|
+
- Check firewall settings
|
|
582
|
+
|
|
583
|
+
### 404 Not Found
|
|
584
|
+
|
|
585
|
+
- Verify controller path mapping
|
|
586
|
+
- Check if component scanning is configured correctly
|
|
587
|
+
- Ensure application context path is correct
|
|
588
|
+
|
|
589
|
+
### Bean creation error
|
|
590
|
+
|
|
591
|
+
- Check for circular dependencies
|
|
592
|
+
- Verify all required dependencies are autowired
|
|
593
|
+
- Review bean scope and lifecycle
|
|
594
|
+
|
|
595
|
+
This README provides a solid foundation for getting started with Spring Boot development. Refer to SKILL.md for in-depth documentation and EXAMPLES.md for practical code examples.
|