Skip to main content

Posts

Showing posts with the label programming

Spring Security with Spring Boot and MySQL

Spring Security with Spring Boot and MySQL In this tutorial I'll show how to use Spring Security with Spring Boot and MySQL. We'll implement a UserDetailsService provided by Spring Security. It is easy to configure Spring Security with Spring Boot and MySQL. You can also check how to run Spring Boot application inside docker container Steps: 1. Create a Spring Boot project from start.spring.io with following dependencies in your pom.xml file. You can choose gradle also for project dependencies. <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- dev tools for hot reloading --> <dependency> <groupId>org.springframework.b...

Custom error handling in Spring Boot 404 not found and 5xx internal server error

We are familiar with the well known whitelabel error in Spring Boot. It appears when the application will not find the resource the user is looking for or any internal application error. This application will demonstrate on how to handle these errors. Spring Boot 1.5.3 has made it easy to handle such error by providing the easy implementation on the user side. First, let us create a simple Spring Boot application. You can use any IDE or go to start.spring.io and create your project. After creating your project, run it as Java application (In eclipse, right click the project -> Run as -> Java Application) or Spring Boot application if you have STS installed. You can download the source code from here . Now, try to access localhost:8080 and you'll see the first whitelabel error because spring boot application is looking for index.html but we haven't defined anything in our application. So, you'll see the error like this. Now, let us create index.html in...