- Framework: Spring Boot v2.0.4
- Java 8
- Thymeleaf
- Bootstrap v.4.3.1
- Create project from Initializr: File > New > project > Spring Initializr
- Add lib repository into pom.xml
- Add folders
- Source root: src/main/java
- View: src/main/resources
- Static: src/main/resource/static
- Create database with name "demo" as configuration in application.properties
- Run sql script to create table doc/data.sql
- Create mapping domain class and place in package com.nnk.springboot.domain
- Create repository class and place in package com.nnk.springboot.repositories
- Create controller class and place in package com.nnk.springboot.controllers
- Create view files and place in src/main/resource/templates
- Create unit test and place in package com.nnk.springboot in folder test > java
- Create user service to load user from database and place in package com.nnk.springboot.services
- Add configuration class and place in package com.nnk.springboot.config
- Add Authorization: redirect based on Role
To start the project, add in application.properties
:
logging.level.com.nnk.springboot=Debug
logging.level.web=debug
logging.level.org.hibernate=error
logging.file=log/poseidon-app.log
spring.security.oauth2.client.registration.github.client-id={github_client_ID}
spring.security.oauth2.client.registration.github.client-secret={github_Secret}
logging.pattern.console=%d{yyyy-MM-dd} [%thread] %-5level %logger{50} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} === [%thread] === %-5level === %logger{50} === %msg%n
################### DataSource Configuration ##########################
spring.jpa.database=mysql
spring.jpa.database-platform=mysql
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/poseidon?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&characterEncoding=utf8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=ur_username
spring.datasource.password=ur_password
################### Hibernate Configuration ##########################
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
server.error.whitelabel.enabled=false