Blog

Spring JdbcAggregateTemplate Example

Spring’s JdbcAggregateTemplate gives you more granular control over the operations that are being performed on your database. JdbcAggregateTemplate exposes operations that are used by Spring Repositories internally, allowing you to invoke database operations that would not otherwise be available using a standard JDBC Repository. This template can be useful for situations when you want to …

Spring JDBC BeforeSaveCallback Example

When using Spring JDBC, there are a number of callbacks available to the developer that can be used to intercept various lifecycle stages of entities within the scope of JDBC. BeforeSaveCallback is used in Spring after an insert or update operation but before the actual database operation has occurred. This gives you the opportunity check …

Spring AsyncRestTemplate is now Deprecated

As part of the Spring 5.0 release, a large number of the Asynchronous HTTP classes have been deprecated in favor of Spring’s new reactive ClientRequest and WebClient classes. Here is a before and after on how you can update your RestTemplate code to the latest non-deprecated way of performing API calls in Spring. Deprecated AsyncRestTemplate Example Here …

Common Maven fixes for transitive CVEs

CVE-2021-29425 - commons-io vulnerability fix Apache commons-io versions 2.6 or below contain a vulnerability in the FileNameUtils class that opens an application up to directory traversal attacks. Paths containing ../ will not be normalized resulting in a path being passed that could cause the application to access files unintended by the developer. Older versions of …

Forwarded Headers Example in Spring

When configuring one or more Spring Boot applications behind a netscaler, load balancer, or reverse proxy, it is possible that the URI’s presented at the browser level do not align with those which are being referenced within Spring. In such a configuration, it is helpful to have the external URL. Take for example a situation …

Spring Milestone and Snapshot Maven Repositories

If you want to access milestone releases, snapshots, nightly builds, and release candidates, you will need some extra configuration in your pom.xml file as these aren’t usually published to Maven central. You can access these by adding the following to the main block of your pom.xml file: Adding snapshot versions of Spring dependencies is as easy …

IntelliJ Spring Boot Starter Not Found Error

I frequently encounter what I suspect is a Maven issue within IntelliJ when attempting to change the version of a Spring Boot Starter Parent. It also sometimes happens upon the initial addition of any Maven parent dependencies into a project’s pom.xml file. This usually results in the following error within IntelliJ’s Problems tab: …