Open in browser http://localhost:<server-port>/swagger-ui/index.html
server port value by default is: 8080
, but you can adjust in the /application.yml
file
– If you want to use PostgreSQL:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
– or MySQL:
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
Open src/main/resources/application.yml
- For PostgreSQL:
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/dbname
username: root
password: root
jpa:
hibernate:
ddl-auto: update # Hibernate ddl auto (create, create-drop, validate, update)
show-sql: true
database: postgresql
database-platform: org.hibernate.dialect.PostgreSQLDialect
security:
jwt:
secret: jwtSecretKey
expiration: 86400000 # 24 hours
- For MySQL
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/dbname
username: root
password: root
jpa:
hibernate:
ddl-auto: update # Hibernate ddl auto (create, create-drop, validate, update)
show-sql: true
security:
jwt:
secret: jwtSecretKey
expiration: 86400000 # 24 hours
– multi data
INSERT INTO roles (id, name) VALUES
(gen_random_uuid(), 'ROLE_ADMIN'),
(gen_random_uuid(), 'ROLE_USER'),
(gen_random_uuid(), 'ROLE_MODERATOR');
– single data
INSERT INTO roles (id, name) VALUES
(gen_random_uuid(), 'ROLE_MODERATOR');
For more detail, please visit:
Secure Spring Boot with Spring Security & JWT Authentication