1- # Spring Boot JWT Authentication example with Spring Security & PostgreSQL
1+ # Spring Boot JWT Authentication example with Spring Security & Spring Data JPA
22
33For more detail, please visit:
44> [ Secure Spring Boot App with Spring Security & JWT Authentication] ( https://bezkoder.com/spring-boot-jwt-authentication/ )
@@ -9,7 +9,54 @@ For more detail, please visit:
99
1010> [ Spring Boot + Angular 8 JWT Authentication] ( https://bezkoder.com/angular-spring-boot-jwt-auth/ )
1111
12+ ## Dependency
13+ – If you want to use PostgreSQL:
14+ ``` xml
15+ <dependency >
16+ <groupId >org.postgresql</groupId >
17+ <artifactId >postgresql</artifactId >
18+ <scope >runtime</scope >
19+ </dependency >
20+ ```
21+ – or MySQL:
22+ ``` xml
23+ <dependency >
24+ <groupId >mysql</groupId >
25+ <artifactId >mysql-connector-java</artifactId >
26+ <scope >runtime</scope >
27+ </dependency >
28+ ```
29+ ## Configure Spring Datasource, JPA, App properties
30+ Open ` src/main/resources/application.properties `
31+ - For PostgreSQL:
32+ ```
33+ spring.datasource.url= jdbc:postgresql://localhost:5432/testdb
34+ spring.datasource.username= postgres
35+ spring.datasource.password= 123
36+
37+ spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
38+ spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
39+
40+ # Hibernate ddl auto (create, create-drop, validate, update)
41+ spring.jpa.hibernate.ddl-auto= update
1242
43+ # App Properties
44+ bezkoder.app.jwtSecret= bezKoderSecretKey
45+ bezkoder.app.jwtExpirationMs= 86400000
46+ ```
47+ - For MySQL
48+ ```
49+ spring.datasource.url= jdbc:mysql://localhost:3306/testdb?useSSL=false
50+ spring.datasource.username= root
51+ spring.datasource.password= 123456
52+
53+ spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
54+ spring.jpa.hibernate.ddl-auto= update
55+
56+ # App Properties
57+ bezkoder.app.jwtSecret= bezKoderSecretKey
58+ bezkoder.app.jwtExpirationMs= 86400000
59+ ```
1360## Run Spring Boot application
1461```
1562mvn spring-boot:run
0 commit comments