Finecloud

My public notes about various information technology topics... 

Building Spring Boot Docker Images

Pre-Requirements Developer Environment ready with Docker, JDK, IDE A Java Spring Boot Project with a h2 in-memory DB Docker Hub account Create Docker File Create a Dockerfile with the following content: FROM openjdk:11-jre-slim ENV JAVA_OPTS " -Xms512m -Xmx512m -Djava.security.egd=file:///dev/./urandom" WORKDIR application COPY target/myapp-0.0.1-SNAPSHOT.jar ./ ENTRYPOINT…

Continue reading...

Data Validation Overview

What is Validation? Validation is a process of making assertions against data to ensure data integrity Is a value required? How long is a phone number? Is it a good date? What is the maximum length of a string? Some refer to data validation as…

Continue reading...

Data Transfer Objects

Data Transfer Objects DTOs - Data Transfer Objects DTOs are simple Java POJOs DTOs are data structures, generally should NOT have behavior DTOs are objects used to transfer data between producers and consumers Controller models are typically DTOs Why Not Entities? Database Entities are also…

Continue reading...

Spring Exception Handling

HTTP Status Codes 100 Series - Informational Responses • 200 Series - Successful Responses 300 Series - Redirection Responses 400 Series - Client Error Responses 500 Series - Server Error Responses Use of HTTP Status Codes 200 Series are used when the request completes as…

Continue reading...

Testing with MockMVC

Why use Spring MockMVC? Spring MockMVC allows you to test the controller interactions in a servlet context without the application running in an application server. Mockito is the most popular mocking framework for testing Java Mocks (aka Test Doubles) are alternate implementations of objects to…

Continue reading...