Quantcast
Channel: Baeldung
Browsing all 4535 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Testing @Cacheable on Spring Data Repositories

1. Overview In addition to implementations, we can use Spring's declarative caching mechanism to annotate interfaces. For instance, we can declare caching on a Spring Data repository. In this tutorial,...

View Article


Image may be NSFW.
Clik here to view.

Injecting Spring Beans into Unmanaged Objects

1. Driving Forces In a Spring application, injecting one bean into another bean is very common. However, sometimes it's desirable to inject a bean into an ordinary object. For instance, we may want to...

View Article


Image may be NSFW.
Clik here to view.

Getting the Week Number From Any Date

1. Introduction In this article, we'll study several options that we can use in Java to get the week number for a given date. We'll start by looking at a few options for legacy code using classes prior...

View Article

Image may be NSFW.
Clik here to view.

Test a Mock JNDI Datasource with Spring

1. Overview Typically, when testing an application that uses JNDI, we may want to use a mocked datasource instead of a real one. This is a common practice when testing in order to make our unit tests...

View Article

Image may be NSFW.
Clik here to view.

The Difference between RxJava API and the Java 9 Flow API

1. Introduction Java Flow API was introduced in Java 9 as an implementation of Reactive Stream Specification. In this tutorial, we'll first investigate reactive streams. Then, we'll learn about its...

View Article


Image may be NSFW.
Clik here to view.

Java IOException “Too many open files”

1. Introduction A common pitfall when working with files in Java is the possibility of running out of available file descriptors. In this tutorial, we'll take a look at this situation and offer two...

View Article

Image may be NSFW.
Clik here to view.

Java Weekly, Issue 338

1. Spring and Java >> The path towards Spring Boot native applications [spring.io] It's great to see some solid development – when it comes to Spring Boot native images! >> Using Multiple...

View Article

Image may be NSFW.
Clik here to view.

Liveness and Readiness Probes in Spring Boot

1. Overview In this tutorial, we're going to see how Spring Boot 2.3 integrates with Kubernetes probes to create an even more pleasant cloud-native experience. First, we'll start with a little bit of a...

View Article


Image may be NSFW.
Clik here to view.

Spring @RequestParam vs @PathVariable Annotations

1. Overview In this quick tutorial, we’ll explore the differences between Spring's @RequestParam and @PathVariable annotations. @RequestParam and @PathVariable can both be used to extract values from...

View Article


Image may be NSFW.
Clik here to view.

Redirecting Logged-in Users with Spring Security

1. Overview It's common for websites to keep their users from visiting the login when they are already logged in. A common way to do that is to redirect the user to another page, usually the starting...

View Article

Image may be NSFW.
Clik here to view.

Why Not To Start A Thread In The Constructor?

1. Overview In this quick tutorial, we're going to see why we shouldn't start a thread inside a constructor. First, we'll briefly introduce the publication concept in Java and JVM. Then, we'll see how...

View Article

Image may be NSFW.
Clik here to view.

Spring Boot and Caffeine Cache

1. Overview Caffeine cache is a high-performance cache library for Java. In this short tutorial, we'll see how to use it with Spring Boot. 2. Dependencies To get started with Caffeine and Spring Boot,...

View Article

Image may be NSFW.
Clik here to view.

Testing Exceptions with Spring MockMvc

1. Overview In this short article, we'll see how exceptions should be thrown in our controllers and how to test these exceptions using Spring MockMvc. 2. Throwing Exceptions in Controllers Let's start...

View Article


Image may be NSFW.
Clik here to view.

Conditional CSS Classes in Thymeleaf

1. Overview In this quick tutorial, we'll learn a few different ways to conditionally add CSS classes in Thymeleaf. If you are unfamiliar with Thymeleaf, we recommend checking our introduction to it....

View Article

Image may be NSFW.
Clik here to view.

Spring RestTemplate Request/Response Logging

1. Overview In this tutorial, we're going to learn how to implement efficient RestTemplate request/response logging. This is especially useful to debug exchange between two servers. Unfortunately,...

View Article


Image may be NSFW.
Clik here to view.

WildFly Administration Remote Access

1. Introduction WildFly provides different approaches for server administration. The most familiar approach is to use its web interface, but we can use the CLI or XML scripts. In this tutorial, we'll...

View Article

Image may be NSFW.
Clik here to view.

Implementing a 2048 Solver in Java

1. Introduction Recently, we looked at an algorithm for solving the game 2048. We discussed this from a theoretical point of view, and not with any real code behind it. Here we're going to write an...

View Article


Image may be NSFW.
Clik here to view.

Groovy Variable Scope

1. Introduction In this tutorial, we'll talk about how to work with the different Groovy scopes and see how we can take advantage of its variable scope 2. Dependencies Throughout, we'll use the...

View Article

Image may be NSFW.
Clik here to view.

Converting a Spring MultipartFile to a File

1. Overview In this quick tutorial, we'll cover various ways of converting a Spring MultipartFile to a File. 2. MultipartFile#getBytes MultipartFile has a getBytes() method that returns a byte array of...

View Article

Image may be NSFW.
Clik here to view.

Number Formatting in Java

1. Overview In this tutorial, we'll look at different approaches to number formatting in Java and how to implement them. 2. Basic Number Formatting with String#format The String#format method is very...

View Article
Browsing all 4535 articles
Browse latest View live