A CRUD application to learn and implement spring concepts.
- Spring Boot
- IoC aka DI injection
- Swagger for Rest API documentation
- Spring Security
- Spring AOP
API's can be accessed by providing Base64 encoded credentials with each request, using HTTP [Authorization] header. Also need to exclude Swagger-UI resources from security configuration in order to be accessible without credentials.
API's can be protected against user roles in WebSecurityConfiguration.java file.
http.antMatchers("/users/*").hasRole("USER")
Method level security can be enabled using
@EnableGlobalMethodSecurity(prePostEnabled = true)
Then you can use @PreAuthorize annotaion on methods.
@PreAuthorize("hasRole('ADMIN')")
or@PreAuthorize("hasAuthority('ROLE_ADMIN')")
AOP addresses the problem of cross-cutting concerns, which would be any kind of code that is repeated in different methods and
can't normally be completely refactored into its own module, like with logging or verification. So, with AOP you can leave that
stuff out of the main code and define it vertically.
Mostly used for logging
and verification
.
Spring docs
- Validating spring properties on bootstrap and fail fast if any important property is missing.
BeanFactoryPostProcessor is used in VerifierBean for this purpose.
- StartupLoggingBean implemented to log some environment info at application startup
OpenPojo is used to test getters/setters automatically.
See this tutorial for full capabilities of OpenPojo.
EqualsVerifier is used to test equals and hashCode methods.
- Swagger UI can be seen using this URL : /estore/swagger-ui.html
Prerequisites
- SonarQube already installed and running (url=my.sonar.host:9000)
Run following command to analyze project and post results on sonar server
mvn clean install -Psonar sonar:sonar
Run following command for code coverage and post results on sonar server
mvn clean install sonar:sonar
It is used to run unit tests.
It is used to run integration tests.
This plugin will not fail build during mvn integration-test
phase.
Failsafe plugin only executes test classes named */IT.java, **/*IT.java, **/*ITCase.java