Skip to content

Commit eea3369

Browse files
committed
Readme improvements
1 parent cd20904 commit eea3369

File tree

1 file changed

+117
-53
lines changed

1 file changed

+117
-53
lines changed

README.md

Lines changed: 117 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,93 @@
11
# SpringBoot Tutorial
22
![Java Maven CI](https://github.com/jssaggu/springboot-tutorial/actions/workflows/maven.yml/badge.svg)
33

4-
## Videos Available here
5-
All the tutorial videos are available on Saggu.uk YouTube channel.
4+
A comprehensive Spring Boot tutorial project demonstrating various Spring Boot features and best practices.
5+
6+
## Video Tutorials
7+
All tutorial videos are available on the Saggu.uk YouTube channel.
68

79
[![Watch the video](docs/Spring-Tutorial-Playlist.png)](https://www.youtube.com/playlist?list=PLYwGWvgqiQCkgxraQU-fuOiYzNCcjGAlz)
810

9-
## Spring Profiles
11+
## Table of Contents
12+
- [Prerequisites](#prerequisites)
13+
- [Getting Started](#getting-started)
14+
- [Project Structure](#project-structure)
15+
- [Features](#features)
16+
- [Spring Profiles](#spring-profiles)
17+
- [Spring Caching](#spring-caching)
18+
- [Database Migration](#flyway)
19+
- [Development](#development)
20+
- [Contributing](#contributing)
21+
22+
## Prerequisites
23+
- Java 17 or later
24+
- Maven 3.6+
25+
- Docker (optional, for running Redis and databases)
26+
- IDE (IntelliJ IDEA recommended)
27+
28+
## Getting Started
29+
30+
1. Clone the repository:
31+
```bash
32+
git clone https://github.com/jssaggu/springboot-tutorial.git
33+
cd springboot-tutorial
34+
```
1035

11-
#### How to run using a profile?
36+
2. Build the project:
37+
```bash
38+
mvn clean install -DskipTests
39+
```
1240

41+
3. Run the application:
42+
```bash
43+
mvn spring-boot:run
1344
```
14-
mvn spring-boot:run -DskipTests -Dspring-boot.run.profiles={Profile-Name}
45+
46+
## Project Structure
47+
```
48+
src/
49+
├── main/
50+
│ ├── java/ # Java source code
51+
│ ├── resources/ # Configuration files
52+
│ └── docker/ # Docker configuration
53+
└── test/ # Test files
1554
```
1655

17-
e.g. For Dev
56+
## Features
1857

19-
```
58+
### Spring Profiles
59+
60+
Spring profiles allow you to configure different environments (dev, prod, test) for your application.
61+
62+
#### How to run using a profile?
63+
64+
```bash
2065
mvn spring-boot:run -DskipTests -Dspring-boot.run.profiles={Profile-Name}
2166
```
2267

23-
e.g. Different Port
24-
68+
Examples:
69+
- For Dev profile:
70+
```bash
71+
mvn spring-boot:run -DskipTests -Dspring-boot.run.profiles=dev
2572
```
73+
74+
- For different ports:
75+
```bash
2676
mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8080
27-
mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8090
2877
```
2978

30-
or
31-
32-
```
33-
mvn clean install -DskipTests
79+
Or using the JAR:
80+
```bash
3481
java -jar target/springboot-tutorial-0.0.1-SNAPSHOT.jar --server.port=8080 --management.server.port=9090
3582
```
3683

37-
## Spring Caching
84+
### Spring Caching
3885

39-
*Note:* Just enable one cache provider
86+
The project supports multiple caching providers. **Note:** Enable only one cache provider at a time.
4087

41-
### Redis
88+
#### Redis Cache
4289

43-
###### Dependency
90+
1. Add the dependency:
4491
```xml
4592
<dependency>
4693
<groupId>org.springframework.boot</groupId>
@@ -49,8 +96,7 @@ java -jar target/springboot-tutorial-0.0.1-SNAPSHOT.jar --server.port=8080 --man
4996
</dependency>
5097
```
5198

52-
###### application.yml
53-
Add the following:
99+
2. Configure in `application.yml`:
54100
```yaml
55101
spring:
56102
cache:
@@ -59,14 +105,15 @@ spring:
59105
type: redis
60106
```
61107
62-
###### How to install Redis using Docker?
63-
64-
* docker pull redis
65-
* docker run --name saggu.uk -p 6379:6379 -d redis
108+
3. Run Redis using Docker:
109+
```bash
110+
docker pull redis
111+
docker run --name saggu.uk -p 6379:6379 -d redis
112+
```
66113

67-
### Hazelcast
114+
#### Hazelcast Cache
68115

69-
###### Dependency
116+
1. Add the dependency:
70117
```xml
71118
<dependency>
72119
<groupId>com.hazelcast</groupId>
@@ -75,7 +122,7 @@ spring:
75122
</dependency>
76123
```
77124

78-
###### Add hazelcast.yaml
125+
2. Add `hazelcast.yaml`:
79126
```yaml
80127
hazelcast:
81128
network:
@@ -84,36 +131,53 @@ hazelcast:
84131
enabled: true
85132
```
86133
87-
# Flyway
88-
89-
### Using Maven
134+
### Database Migration (Flyway)
90135
91-
#### H2
92-
`mvn clean -Dflyway.configFiles=src/main/docker/flyway-h2.conf -Dflyway.locations=filesystem:src/main/resources/db/migration/ flyway:migrate`
93-
#### Postgres
94-
`mvn clean -Dflyway.configFiles=src/main/docker/flyway-postgres.conf -Dflyway.url=jdbc:postgresql://localhost:5432/postgres -Dflyway.locations=filesystem:src/main/resources/db/migration/ flyway:migrate`
136+
#### Using Maven
95137
96-
### Other goals
97-
Official doc: https://flywaydb.org/documentation/usage/maven/
138+
For H2:
139+
```bash
140+
mvn clean -Dflyway.configFiles=src/main/docker/flyway-h2.conf -Dflyway.locations=filesystem:src/main/resources/db/migration/ flyway:migrate
141+
```
98142

99-
| Name | Description |
100-
|:--------:|----------------------------------------------------------------------------------------------|
101-
| migrate | Migrates the database |
102-
| clean | Drops all objects in the configured schemas |
103-
| info | Prints the details and status information about all the migrations |
104-
| validate | Validates the applied migrations against the ones available on the classpath |
105-
| undo | Flyway Teams Undoes the most recently applied versioned migration |
106-
| baseline | Baselines an existing database, excluding all migrations up to and including baselineVersion |
107-
| repair | Repairs the schema history table |
143+
For PostgreSQL:
144+
```bash
145+
mvn clean -Dflyway.configFiles=src/main/docker/flyway-postgres.conf -Dflyway.url=jdbc:postgresql://localhost:5432/postgres -Dflyway.locations=filesystem:src/main/resources/db/migration/ flyway:migrate
146+
```
108147

109-
#### Connect to H2 Database from IntelliJ
110-
Database > Add New > H2
111-
URL: `jdbc:h2:file:./springboot-tutorial/target/foobar`<br>
112-
UserName: sa<br>
113-
Pwd: <Empty>
148+
#### Available Flyway Commands
149+
150+
| Command | Description |
151+
|-----------|----------------------------------------------------------------------------------------------|
152+
| migrate | Migrates the database |
153+
| clean | Drops all objects in the configured schemas |
154+
| info | Prints the details and status information about all the migrations |
155+
| validate | Validates the applied migrations against the ones available on the classpath |
156+
| undo | Undoes the most recently applied versioned migration (Flyway Teams) |
157+
| baseline | Baselines an existing database, excluding all migrations up to and including baselineVersion |
158+
| repair | Repairs the schema history table |
159+
160+
#### Database Connection
161+
162+
##### H2 Database
163+
- URL: `jdbc:h2:file:./springboot-tutorial/target/foobar`
164+
- Username: `sa`
165+
- Password: (empty)
166+
167+
##### Using Docker
168+
Run the following command from the `src/main/docker` directory:
169+
```bash
170+
docker compose up -d
171+
```
114172

115-
### Using Docker
173+
## Development
116174

117-
Run `docker compose up -d` from `src/main/docker` folder.
175+
### IDE Setup
176+
For IntelliJ IDEA:
177+
1. Open the project
178+
2. Import as Maven project
179+
3. Enable annotation processing
180+
4. Configure H2 database connection as described above
118181

119-
Login to DBeaver
182+
## Contributing
183+
Contributions are welcome! Please feel free to submit a Pull Request.

0 commit comments

Comments
 (0)