Skip to content

Commit 10ae6fd

Browse files
committed
update to Spring Boot 3
1 parent 29b1ce2 commit 10ae6fd

File tree

16 files changed

+559
-561
lines changed

16 files changed

+559
-561
lines changed

README.md

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,37 @@ You can have an overview of our Spring Boot Server with the diagram below:
1010

1111
![spring-boot-spring-security-postgresql-jwt-authentication-architecture](spring-boot-spring-security-postgresql-jwt-authentication-architecture.png)
1212

13+
## Configure Spring Datasource, JPA, App properties
14+
Open `src/main/resources/application.properties`
15+
16+
```
17+
spring.datasource.url= jdbc:postgresql://localhost:5432/testdb
18+
spring.datasource.username= postgres
19+
spring.datasource.password= 123
20+
21+
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
22+
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
23+
24+
# Hibernate ddl auto (create, create-drop, validate, update)
25+
spring.jpa.hibernate.ddl-auto= update
26+
27+
# App Properties
28+
bezkoder.app.jwtSecret= ======================BezKoder=Spring===========================
29+
bezkoder.app.jwtExpirationMs= 86400000
30+
```
31+
32+
## Run Spring Boot application
33+
```
34+
mvn spring-boot:run
35+
```
36+
37+
## Run following SQL insert statements
38+
```
39+
INSERT INTO roles(name) VALUES('ROLE_USER');
40+
INSERT INTO roles(name) VALUES('ROLE_MODERATOR');
41+
INSERT INTO roles(name) VALUES('ROLE_ADMIN');
42+
```
43+
1344
For more detail, please visit:
1445
> [Spring Boot, Spring Security, PostgreSQL: JWT Authentication & Authorization example](https://bezkoder.com/spring-boot-security-postgresql-jwt-authentication/)
1546
@@ -30,8 +61,16 @@ For instruction: [Spring Boot Refresh Token with JWT example](https://bezkoder.c
3061
3162
> [Spring Boot Repository Unit Test with @DataJpaTest](https://bezkoder.com/spring-boot-unit-test-jpa-repo-datajpatest/)
3263
64+
> [Spring Boot Rest Controller Unit Test with @WebMvcTest](https://www.bezkoder.com/spring-boot-webmvctest/)
65+
3366
> [Spring Boot Pagination & Sorting example](https://www.bezkoder.com/spring-boot-pagination-sorting-example/)
3467
68+
> Validation: [Spring Boot Validate Request Body](https://www.bezkoder.com/spring-boot-validate-request-body/)
69+
70+
> Documentation: [Spring Boot and Swagger 3 example](https://www.bezkoder.com/spring-boot-swagger-3/)
71+
72+
> Caching: [Spring Boot Redis Cache example](https://www.bezkoder.com/spring-boot-redis-cache-example/)
73+
3574
Associations:
3675
> [Spring Boot One To Many example with Spring JPA, Hibernate](https://www.bezkoder.com/jpa-one-to-many/)
3776
@@ -55,6 +94,10 @@ Associations:
5594
5695
> [Spring Boot + Angular 14 JWT Authentication](https://www.bezkoder.com/angular-14-spring-boot-jwt-auth/)
5796
97+
> [Spring Boot + Angular 15 JWT Authentication](https://www.bezkoder.com/angular-15-spring-boot-jwt-auth/)
98+
99+
> [Spring Boot + Angular 16 JWT Authentication](https://www.bezkoder.com/angular-16-spring-boot-jwt-auth/)
100+
58101
> [Spring Boot + React JWT Authentication](https://bezkoder.com/spring-boot-react-jwt-auth/)
59102
60103
## Fullstack CRUD App
@@ -73,6 +116,10 @@ Associations:
73116
74117
> [Angular 14 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-14-postgresql/)
75118
119+
> [Angular 15 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-15-postgresql/)
120+
121+
> [Angular 16 + Spring Boot + PostgreSQL example](https://www.bezkoder.com/spring-boot-angular-16-postgresql/)
122+
76123
> [React + Spring Boot + PostgreSQL example](https://bezkoder.com/spring-boot-react-postgresql/)
77124
78125
Run both Back-end & Front-end in one place:
@@ -81,63 +128,3 @@ Run both Back-end & Front-end in one place:
81128
> [Integrate React.js with Spring Boot Rest API](https://bezkoder.com/integrate-reactjs-spring-boot/)
82129
83130
> [Integrate Vue.js with Spring Boot Rest API](https://bezkoder.com/integrate-vue-spring-boot/)
84-
85-
## Dependency
86-
```xml
87-
<dependency>
88-
<groupId>org.springframework.boot</groupId>
89-
<artifactId>spring-boot-starter-data-jpa</artifactId>
90-
</dependency>
91-
92-
<dependency>
93-
<groupId>org.springframework.boot</groupId>
94-
<artifactId>spring-boot-starter-security</artifactId>
95-
</dependency>
96-
97-
<dependency>
98-
<groupId>org.springframework.boot</groupId>
99-
<artifactId>spring-boot-starter-web</artifactId>
100-
</dependency>
101-
<dependency>
102-
<groupId>org.postgresql</groupId>
103-
<artifactId>postgresql</artifactId>
104-
<scope>runtime</scope>
105-
</dependency>
106-
107-
<dependency>
108-
<groupId>io.jsonwebtoken</groupId>
109-
<artifactId>jjwt</artifactId>
110-
<version>0.9.1</version>
111-
</dependency>
112-
```
113-
114-
## Configure Spring Datasource, JPA, App properties
115-
Open `src/main/resources/application.properties`
116-
117-
```
118-
spring.datasource.url= jdbc:postgresql://localhost:5432/testdb
119-
spring.datasource.username= postgres
120-
spring.datasource.password= 123
121-
122-
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
123-
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
124-
125-
# Hibernate ddl auto (create, create-drop, validate, update)
126-
spring.jpa.hibernate.ddl-auto= update
127-
128-
# App Properties
129-
bezkoder.app.jwtSecret= bezKoderSecretKey
130-
bezkoder.app.jwtExpirationMs= 86400000
131-
```
132-
133-
## Run Spring Boot application
134-
```
135-
mvn spring-boot:run
136-
```
137-
138-
## Run following SQL insert statements
139-
```
140-
INSERT INTO roles(name) VALUES('ROLE_USER');
141-
INSERT INTO roles(name) VALUES('ROLE_MODERATOR');
142-
INSERT INTO roles(name) VALUES('ROLE_ADMIN');
143-
```

pom.xml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
34
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
45
<modelVersion>4.0.0</modelVersion>
56
<parent>
67
<groupId>org.springframework.boot</groupId>
78
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.7.3</version>
9-
<relativePath/> <!-- lookup parent from repository -->
9+
<version>3.1.0</version>
10+
<relativePath /> <!-- lookup parent from repository -->
1011
</parent>
1112
<groupId>com.bezkoder</groupId>
1213
<artifactId>spring-boot-security-postgresql</artifactId>
@@ -15,25 +16,25 @@
1516
<description>Spring Boot, Spring Security, PostgreSQL: JWT Authentication &amp; Authorization example</description>
1617

1718
<properties>
18-
<java.version>1.8</java.version>
19+
<java.version>17</java.version>
1920
</properties>
2021

2122
<dependencies>
2223
<dependency>
2324
<groupId>org.springframework.boot</groupId>
2425
<artifactId>spring-boot-starter-data-jpa</artifactId>
2526
</dependency>
26-
27+
2728
<dependency>
2829
<groupId>org.springframework.boot</groupId>
2930
<artifactId>spring-boot-starter-security</artifactId>
3031
</dependency>
31-
32+
3233
<dependency>
33-
<groupId>org.springframework.boot</groupId>
34-
<artifactId>spring-boot-starter-validation</artifactId>
35-
</dependency>
36-
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-validation</artifactId>
36+
</dependency>
37+
3738
<dependency>
3839
<groupId>org.springframework.boot</groupId>
3940
<artifactId>spring-boot-starter-web</artifactId>
@@ -44,19 +45,33 @@
4445
<artifactId>postgresql</artifactId>
4546
<scope>runtime</scope>
4647
</dependency>
47-
48+
49+
<dependency>
50+
<groupId>io.jsonwebtoken</groupId>
51+
<artifactId>jjwt-api</artifactId>
52+
<version>0.11.5</version>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>io.jsonwebtoken</groupId>
57+
<artifactId>jjwt-impl</artifactId>
58+
<version>0.11.5</version>
59+
<scope>runtime</scope>
60+
</dependency>
61+
4862
<dependency>
4963
<groupId>io.jsonwebtoken</groupId>
50-
<artifactId>jjwt</artifactId>
51-
<version>0.9.1</version>
64+
<artifactId>jjwt-jackson</artifactId>
65+
<version>0.11.5</version>
66+
<scope>runtime</scope>
5267
</dependency>
53-
68+
5469
<dependency>
5570
<groupId>org.springframework.boot</groupId>
5671
<artifactId>spring-boot-starter-test</artifactId>
5772
<scope>test</scope>
5873
</dependency>
59-
74+
6075
<dependency>
6176
<groupId>org.springframework.security</groupId>
6277
<artifactId>spring-security-test</artifactId>

0 commit comments

Comments
 (0)