Author: Sergey Kargopolov

I’m a software developer with a passion for teaching. I’ve written lots of articles for AppsDeveloperBlog.com and made plenty of video tutorials on my YouTube channel(https://youtube.com/@SergeyKargopolov). If you want to dive deeper, I’ve also got some courses on Udemy(https://www.udemy.com/user/sergeykargopolov/) you might like.

When I’m not coding, I love to travel. I also share my travel adventures over at TravelLocalCanada.com. Hope to see you around on one of these platforms!

Web: www.appsdeveloperblog.com

This tutorial will teach you how to add Spring Security to your project and enable in-memory basic authentication. You will learn how to configure two different users with different Roles and Privileges. Both users’ roles and privileges will be stored in the memory of your Spring Boot application. If you use Spring Framework and OAuth,…

Read More Spring Security In-Memory Authentication

In this tutorial, you will learn how to write a JUnit test that validates whether the method under test throws the correct exception. The tutorial includes examples for both JUnit 5 and JUnit 4. For video lessons, check out my video course: Testing Java with JUnit and Mockito. Let’s begin with JUnit 5 version first.…

Read More Test for Exception in JUnit 5 and JUnit 4

In this tutorial, I am going to share with you a few different techniques you can use to iterate over a collection in Java. Iterating ArrayList with Enhanced For-Loop List<String> names = new ArrayList<>(); names.add(“Sergey”); names.add(“Bill”); names.add(“John”); for(String name: names) { System.out.println(name); } Output: Sergey Bill John We declare a List of String objects named…

Read More Iterating over Collections in Java: Examples

Dependency injection is a design pattern in which a component’s dependencies are supplied externally rather than being hardcoded within the component itself. In Spring, developers mainly use 3 different types of dependency injection: constructor-based, setter-based, and field-based. In this tutorial, we will see how to use Setter-based Dependency Injection to inject a UsersRepository into a…

Read More Setter-based Dependency Injection in Spring

Learning how to convert Java objects into JSON and vice versa can be very helpful for your work as a full-stack mobile app developer. In this blog post, I will share some code examples that will help you with the most common tasks you’ll encounter when working with JSON and Java. I will cover the…

Read More Convert Java into JSON and JSON into Java. All Possible Examples.

Maven is a popular build tool for Java projects. It helps you manage dependencies, build and test your projects, and package them for distribution. Keeping Maven up-to-date is important to take advantage of the latest bug fixes and new features. If you do not have Maven installed on your computer, then read How to install…

Read More Upgrading Maven on macOS

Spring is a popular Java-based framework for building applications. One of its core features is dependency injection, which is used to manage the relationships between objects and to make it easier to manage the dependencies in an application. In this tutorial, we will explore two of the main methods of dependency injection in Spring: constructor…

Read More Constructor vs Field Dependency Injection in Spring

This tutorial will teach you how to start your Spring Boot application on a random port number. Starting an application on a random port number is very helpful when you need to start multiple instances of the same Spring Boot application and then balance HTTP requests between the running instances. If you want to learn…

Read More Start Spring Boot App on a Random Port Number

Dependency Injection is a design pattern that allows the separation of concerns in an application by removing the hard-coded dependencies between objects. In Dependency Injection, the objects are provided with their dependencies instead of having to hard-code them. This makes the application more flexible, maintainable, and easier to test. Spring Framework provides several ways to…

Read More Field-based Dependency Injection in Spring

In this tutorial, you will learn how to download and start up Keycloak as a standalone server. What is Keycloak? Keycloak is an open-source identity and access management tool focusing on modern applications and services such as mobile applications, REST APIs, and single-page applications. How to Download Keycloak? To download the Keycloak go to the…

Read More Keycloak: Starting a Standalone Server