Spring Boot, Keycloak and TestContainer Example
Learn to use the test container library (KeycloakContainer) to start keycloak server as a docker container while unit testing with JUnit and Spring boot.
Learn to use the test container library (KeycloakContainer) to start keycloak server as a docker container while unit testing with JUnit and Spring boot.
Learn to export an existing realm as a JSON file from the Keycloak server, and also to import a previously exported realm file with clients, policies and users.
Understand the root cause and learn to solve the error “Script upload is disabled” when we import a realm file into Keycloak server.
This Spring security tutorial discusses using Keycloak and Spring Security OAuth2 to implement token-based authentication in a spring boot app.
Learn the installation of the Keycloak authorization server as a docker container and different configurations for setting up the realm and testing the authorization token flow.
Learn to configure bulkhead and rate limiting using Resilience4j 2 in a Spring boot 3 application, and testing with Apache JMeter.
Java ConcurrentSkipListMap keeps keys sorted for many threads. Learn skip lists, floor and ceiling keys, live range views, polling and TreeMap differences.
Learn to implement authentication with a user login and logout functionality using Vue.js and Spring Boot Security using JWT tokens.
Spring boot, by default, configures Jackson for parsing objects to JSON. We can use Jackson’s XML module or JAXB to configure the XML support.
Spring @Sql executes DDL and DML SQL scripts and statements during the integration testing. @SqlGroup groups multiple @Sql statements.
Learn to execute SQL scripts to load data (e.g. import.sql, schema.sql or data.sql) during startup of a Spring boot application or tests.
Learn to fix the InaccessibleObjectException or “Failed making field ‘java.time.LocalDate#year’ accessible” type errors when serializing or deserializing the new Java 8 Date time classes.
Learn to integrate Spring Boot with MongoDB using the Spring Data MongoDB API and work with database using MongoTemplate and MongoRepository.
Learn the root cause and solution to fix the authentication error caused when connecting with MongoDB from a Spring boot application.
Fix Java OutOfMemoryError by its message, from heap space and Metaspace to native threads, with JDK 25 output, container settings and heap dump analysis.
Learn how a JSON Web Token (JWT) works, create and validate one with jjwt 0.13 and nimbus-jose-jwt, and avoid the storage, key and expiry mistakes.
JPAstreamer guide with Spring Boot 4 and Hibernate 7. Set up the metamodel, filter, sort and page entities as Java streams, see the SQL and known issues.
Fix class file has wrong version 61.0, should be 52.0 by building with JDK 17+ in Maven, Gradle, IntelliJ and Eclipse. Includes a class version table.
Learn to create an application from scratch using REST APIs created with Spring boot and the user interface created with Vue.js. We will build a simple employee management application with Create, Read, Update, and Delete (CRUD) functionality. 1. Application Overview In the application, the home screen will present a list …
Learn to solve the ‘JdbcSQLSyntaxErrorException schema not found’ error in a Spring boot app that uses the H2 database for CRUD operations.
Deploying a Spring Boot application to Kubernetes can seem daunting at first, but with the right tools and knowledge, it can be a straightforward process. In this post, we will walk through the steps needed to deploy a dockerized Spring Boot application to Kubernetes (Minikube). 1. Prerequisites Before we begin, …
Python interview questions with direct answers and code on data types, functions, classes, exceptions, concurrency, NumPy, pandas and coding problems.
Learn why we need a custom validation annotation and how to create, use and test such a custom validation annotation in Spring MVC.
The Java volatile keyword makes writes visible to other threads but does not make count++ atomic. See happens-before, stop flags and lazy singletons.
Are local variables thread safe in Java? Yes, each thread keeps its own stack copy. See when shared objects, lambdas and escaping references break it.
Convert primitive array to List in Java with boxed().toList(), loops, Guava Ints.asList() and ArrayUtils, and learn why Arrays.asList(int[]) fails.
Learn to handle exceptions in Java streams by wrapping checked exceptions, skipping bad elements with Optional or mapMulti, or collecting errors as values.
Learn Java ZoneId and ZoneOffset with examples. Create zones with ZoneId.of(), list all zone IDs, convert a ZoneId to a ZoneOffset at an instant, handle ZoneRulesException and use ZoneId.SHORT_IDS.
Generate a random number in a range in Java with nextInt(min, max + 1), legacy formulas, doubles, unique values, exclusions and secure codes.
Convert an Instant to ZonedDateTime in Java with atZone() or ofInstant(), choose the right zone, convert back with toInstant() and avoid date shifts.
Convert Instant to LocalDateTime in Java with LocalDateTime.ofInstant(instant, zone). Get LocalDate or LocalTime, pick the right zone, and convert back.
Learn to configure and use different DataSource in different environments (test, development, production etc.) using the Spring profile specific properties files, as well as Java configuration in a Spring boot application. 1. Introduction A production grade application is deployed and tested in different environments before finally released to the end-user. …
Learn to install the database services such as MySQL and PostgreSQL as docker containers and connect to them from Adminer or Spring boot app.
Convert String array to int array in Java with streams and Integer.parseInt(), get an Integer[] and skip or report invalid values safely.
Fix the JMH error Unable to find the resource /META-INF/BenchmarkList on JDK 23+ with Maven processor paths, proc full, Gradle and shaded JARs.
Check if a file exists in Python with Path.is_file() and os.path.isfile(), avoid race conditions with try and open, and handle symlinks and patterns.
Learn to perform integration testing using Testcontainers and JUnit 5 in a Spring boot application, including creating a @ServiceConnection.
Mask a string except the last 4 characters in Java with repeat() or a regex lookahead, keeping dashes in card and phone numbers, null-safe.
Runnable vs Callable in Java explained with examples of return values, checked exceptions, Future, FutureTask, invokeAll and the Java 19 Future methods.
Learn the builder pattern for Java records with a nested builder, Lombok @Builder and RecordBuilder, plus defaults, validation and with methods on Java 25.
Learn to use Spring PartEvent API for streaming multipart requests to a webflux controller and handle the form parameters and file contents.
Since version 6, Spring supports creating an RSocket service as a Java interface with @RSocketExchange annotated methods for TCP exchanges.
Learn the RSocket protocol and implement communication models in Spring boot using reactive types such as Mono and Flux with examples.
Learn what a daemon thread in Java is, how setDaemon() works, why the JVM does not wait for it, virtual threads, executors and when to use one.
Log4j2 delete old logs with the Delete action on rollover. Age, count and size rules, properties config, why files stay, and Logback maxHistory.
Find the max value in a Java Map and its key with streams, Collections.max() or one loop, and handle min values, ties, empty maps and null values safely.
Learn how to enable SQL logging in a Spring boot Data JPA application, print SQL statements and prepare statements with parameter values.
Java OOP interview questions with examples covering encapsulation, inheritance, polymorphism, abstraction, method dispatch and practical design choices.
Assert two lists equal ignoring order with AssertJ, Hamcrest, Commons Collections or plain JUnit 6, and see which assertions count duplicates.
Learn FastExcel to write and read large Excel files in Java with streaming, flush(), typed cell getters, parallel sheets and a comparison with POI.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.