Skip to main content

Posts

Showing posts with the label spring boot

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...

How to run Spring Boot application inside docker container

Step by Step procedure in creating and running a simple Spring Boot application inside docker container This tutorial will show you on how to run simple Spring Boot application inside docker container. If you have not installed docker already, please install it first. I'm using Linux Mint 18.2. You can follow these steps on How To install Docker in Linux Mint 18.2 After you've successfully installed docker in your machine, let's create a docker image that will run inside the container. Create a simple Spring Boot project from here . Select Web as a dependency. Import the project into you IDE, I'm using Spring Tool Suite. Create a controller and name it HelloController. You can name your controller anything you like. Create a method that will map the request and return a response. Create Dockerfile at the root of the project. The name is important here, only the letter D is capital Make the following entries inside the Dockerfile #Enter all the requi...

How To install Docker in Linux Mint 18.2

How To install docker in Linux Mint 18.2 Codename: sonya Docker is a Container as a service (CaaS) platform which helps to eliminate "works in my computer" problems when working together with other members in the team. More here Docker for Linux Mint is availabe as a free Community Edition (CE). Installation is easy and straigh forward. We will install a stable release of docker. OS Requirements Linux Mint 18.2 (LTS) Architecture: x86_64 If you've the older version installed already, uninstall it $ sudo apt-get remove docker docker-engine docker.io Add repositories $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - Since, Linux Mint 18.2 (sonya) is based on Ubuntu 16.04 (xenial), we've to use the release codename of Ubuntu 16.04 i.e. xenial. Also, we'll use the latest stable version $ sudo add-apt-repository "deb [arch=a...

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...