Implementing checkpoint or partial commits within a database transaction in a Spring Boot service can be tricky since Spring transactions are designed to be atomic: they either fully commit or fully roll back. However, you can achieve a similar effect by managing transactions explicitly in your service layer and leveraging Spring’s PlatformTransactionManager or nested transactions…
Category: Spring
How to Execute something after a Spring Bean is Initialized
You can use several methods to Execute something after a Spring Bean is Initialized but the most popular one is the @PostConstruct annotation. Here’s an example: import org.springframework.stereotype.Component; @Component public class MyBean { @PostConstruct public void init() { System.out.println(“My bean is initialized”); // Your code here } } In this example, The Spring Engine will…
Allow Spring Boot Endpoint to be called only from Internal Network
You can achieve an Spring Boot Endpoint to be called only from Internal Network by using the built-in support for security and configuring a filter to check the IP address of incoming requests. Here are the steps: Step 1: Add dependencies In your pom.xml file (if you’re using Maven) or build.gradle file (if you’re using…
How to add SVG to Vaadin
Vaadin is a popular Java framework for building Web Applications, so it is logical to have the ability to add SVG to the Vaadin Web App. Method 1: Using Vaadin’s built-in SVG support Vaadin provides a built-in way to display SVGs using the SVG class. Here’s an example: import com.vaadin.flow.component.html.Div; import com.vaadin.flow.server.VaadinRequest; public class MyUI…
What could be the reason for Spring Repository cannot Delete Record
There are several reasons why a Spring Repository might not be able to Delete a Record. Here are some possible causes: No Transaction Spring Data JPA uses transactions by default, but if you’re not using a transaction manager or the @Transactional annotation, the delete operation might not be committed. Incorrect Query Make sure that the…
File Upload with Spring Boot RestTemplate with Parameters
Here’s an example of how you can use Spring Boot ‘s RestTemplate to Upload a File with additional parameters. First, let’s create a simple REST endpoint that accepts a file and some additional parameters. We’ll use Spring MVC to create this endpoint. FileUploadController.java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping;…
Elastic Search – minimal spring boot integration
You’ve got Elastic Search and Kibana running – here is an example of a minimal Spring Boot application that integrates with Elasticsearch. This article is continueing my previous articles: What Problems Elastic Search resolves? Getting Started Guide for Elastic Search Docker Compose Settinghs Any Software nowadays is delivered through containers. Having your hands dirty by…
2024 Firebase Push Notifications in Vaadin Web [Fail⚠️] App [Mobile✅]
Most recently I’ve tried to Integrate Firebase Push Notifications into a Vaadin Web App and I ended up – getting it – working – on Mobile. Here’s an overview of the steps I’ve done. Using Vaadin’s built-in support for @Push Notifications Vaadin provides ability to “Push” content onto the browser from your server. If you…
what is DTO in Spring Boot
In Spring Boot, a DTO or Data Transfer Object is a simple Java object that is used to transfer data between different layers of an application. DTOs are often used to encapsulate the data that needs to be transferred from one subsystem of an application to another: from database to the service layer from service…
Latest Trends you could code with Java Spring Boot
Java Spring Boot is a powerful framework for building microservices, web applications, and enterprise-level solutions and its popularity is well-suited to several of the latest trends in software development. Here’s how you can leverage Spring Boot to explore these trends, along with relevant libraries and resources: 1. API-First Architecture Libraries: Spring Boot Starter Web: For…