In part 1 we created a Thymeleaf component library that can be used in a Spring Boot application. Part 2 showed how to create an actual component with custom attributes and a passthrough of any attribute. In part 3 we will add support for slots, which allows to add arbitrary content inside a component.
In part 1 we created a Thymeleaf component library that can be used in a Spring Boot application. There is a sample application that uses the library, and there is full live reload support for changing the CSS and JS files in the library. We will create an actual component in the library and use it in the sample application.
This blog series will explain how to write a component library for Thymeleaf. The goal is to create a library that can be used in any Spring Boot application that uses Thymeleaf as the view technology. Users of the library should be able to use the components to quickly build a user interface without having to write a lot of HTML and CSS themselves.
If you use Spring Boot with Thymeleaf, you might be using an external OAuth2 provider like Keycloak or Okta to authenticate your users. In this blog post, I will show you how to test your OAuth2 client login with mock-oauth2-server .
This blog post explains what the Thymeleaf Layout Dialect is, why you might want to stop using it, and how to migrate to a pure Thymeleaf solution using th:replace .
This blog post explains how I like to document a Spring Boot application I am writing. It is the third and last post in my series on writing production-ready Spring Boot applications. See How I write production-ready Spring Boot applications and How I test production-ready Spring Boot applications for the other posts in the series.
My previous blog post How I write production-ready Spring Boot applications explained how I like to write and structure my production code in Spring Boot applications. This blog post will further explain how I write tests for the code.
This blog post will explain how I currently write Spring Boot applications. I have been writing Java for over 25 years, and most of that involved Spring and its ecosystem. I will talk about how I architect my app, package structure, naming conventions, etc.
Testcontainers is a great technology to run Docker containers of dependencies like a database or a messaging middleware like ActiveMq or Kafka. It might not immediately be obvious how to combine JUnit, Testcontainers and Spring Boot when you have multiple containers that your application needs. This blog post aims to provide some guidance on how to combine them.
Last week Tailwind CSS v4.0 was released. This, unfortunately, broke the ttcli tool to generate a Spring Boot with Thymeleaf project when you selected Tailwind CSS.
I really like to use Spring Boot, Thymeleaf and htmx for a productive web application stack. However, most of my day-to-day work involves writing REST API backends (Well, JSON Data APIs really ) for Angular or React frontends. During that work, I sometimes can’t help but think “We would not have this issue we are discussing now if we had used server-side rendering instead of a JavaScript Single…
A common implementation pattern with Spring MVC is showing a notification message after a redirect has happened. For example, you edit a product in a page and after saving the product you are redirected back to the list of products. At the top, you show a message "Product xyz updated". If the user manually refreshes the page, the message should disappear. To implement this, you can use redirect…
I recently started using Slidev for creating presentations. It is a tool to create a Powerpoint/Keynote/Google Slides like presentation, but using Markdown instead. In this blog post, I will explain the basics and share some of my favorite tips and tricks.
This blog post will show you how to create your own React components in a Spring Boot with Thymeleaf project. The setup will use Vite to be able to write the React components in TypeScript and have live reload of the components so you can easily edit them and use them in your Thymeleaf templates. In the end, we will also see how we can use an existing React library in our application.
This blog post will show you how to create your own Web Components in a Spring Boot with Thymeleaf project. The setup will use Vite to be able to write the Web Components in TypeScript and have live reload of the components so you can easily edit them and use them in your Thymeleaf templates.
In my previous blog post Transactional Outbox pattern with Spring Boot , I compared Spring Integration with Spring Modulith to implement the microservices outbox pattern. I mentioned that a drawback of Spring Integration is the fact that Java serialization is used so the data in the database is not readable with standard database tooling.
If you are building a microservice architecture, or you just need to send emails from your monolith, you should look into the Transactional Outbox pattern to ensure reliable communication between services. This blog post shows a few ways how you can implement this using Spring Boot.
Starting a new application can be a daunting task. How will you structure your code? How can you get started quickly? There are a few tools such as JHipster that help you setup your project. One such alternative that I recently looked at is Bootify .
The htmx-spring-boot library 3.2.0 has just been released and now supports using HtmxResponse as a return type for error handlers. This blog post shows how you can use this.
🎉 Thrilled to announce the official release of my new book 'Modern frontends with htmx'! Discover how to master htmx with SpringBoot and Thymeleaf for rich, interactive web applications.
I am happy to announce version 1.0.0 of ttcli . Ttcli is a command line tool to generate a Spring Boot with Thymeleaf project with support for live reloading.
Thymeleaf 3.1.2 was released recently and is inluded in Spring Boot 3.0.10 and 3.1.3 . For security reasons , it is no longer allowed for a Thymeleaf template to directly access org.springframework.web.servlet.support.ServletUriComponentsBuilder . This was used in my Taming Thymeleaf book to build a generic fragment that can be used for pagination controls. If you still use it, you get this…
My book Taming Thymeleaf has just been updated on leanpub for Spring Boot 3. This blog post will walk you through the most important changes if you want to upgrade to Spring Boot 3 from Spring Boot 2 if you used the previous version of the book.
Yesterday, I shared how to combine Thymeleaf, Shoelace and htmx to show toast notifications in your web application. This worked pretty well and only needed a little JavaScript, but we can even further reduce the JavaScript used further and make them even more useful as the same time!
I recently played around with Shoelace , a library of web components. The nice thing about web components is that they are framework agnostic, so we can use them with Thymeleaf as well. This blog post will show how to use the Alert Toast component to show a confirmation or an error to the user. See also part 2 for a similar demo where the HTML of the notifications is generated in Thymeleaf instead…
Building a complete user management system yourself is quite some work. However, you can very easily allow users to use social login with Google for example and avoid having to do all that work yourself. This blog post will show how to quickly setup a Spring Boot with Thymeleaf project and secure it using Google login.
I created the error-handling-spring-boot-starter library for Spring Boot because I was unhappy with the default response that Spring Boot 2 provides out-of-the-box. With Spring Boot 3, there is now support for ProblemDetail and we can have a look on how that changes things.
I started my YouTube channel this week. It was quite something to come to this result, speaking to a camera is quite scary at first, but I think I got a nice result in the end 🙂
Using htmx is a great way to make your Spring Boot with Thymeleaf web application dynamic without page refreshes. Since there are no page refreshes, but transparent AJAX calls going on, it is important to put in error handling code to ensure a good user experience in case something goes wrong. This blog post shows how to do this.
In my blog post of yesterday, I explained how to use Thymeleaf live reload with npm scripts . Quickly after announcing the blog post on Twitter, Oliver Drotbohm asked me why I didn’t just use Spring Boot DevTools instead. A valid question and one I will address in this follow-up post.
UPDATE: I created a follow-up blog Thymeleaf live reload with Spring Boot DevTools that shows a way to have Live Reload with a little less setup work, but some important drawbacks as well in my opionion. Be sure to read both blog posts to get an informed opinion about which path to take. If you want to add Tailwind CSS to your project, go to Thymeleaf live reload with Spring Boot and Tailwind CSS…
My error-handling-spring-boot-starter library had its first release almost 2 years ago. The first reported issue came soon after with a request to support Spring WebFlux. As I don’t have any Spring WebFlux projects myself, it was pretty low on my priority list. Especially as it did not seem trivial to add support. Luckily, about a month ago Fabio Marini opened a PR with all the building blocks I…
I migrated a project from Bootstrap 4 with the Sleek dashboard template to Tailwind CSS as Bootstrap 4 stopped having bugfixes on 2021-07-01, and there is no version for Bootstrap 5. Anyways, I like Tailwind CSS a lot more to work with :) One of the components that the project used is Bootstrap Toggle , which makes a simple checkbox look a lot better. As the project kicked out Bootstrap, I needed…
I released a new version 2.1.0 of the Error Handling Spring Boot Starter last week. It supports nice error messages for validation of request parameters now. This blog post shows some more detail on how you can do validation of request parameters.
This blog post uses htmx 1.6. In htmx 1.7, server-sent events support has been moved to an extension . The example code on GitHub has been updated to work with htmx 1.7. See commit b46b15b for the (small) changes that are needed. It is possible to push information from a Spring Boot backend to the UI using either Websockets or Server-Sent Events. This blog post will show how to use Thymeleaf with…
The hibernate-types library has extra types that are not found in Hibernate by default. One of the most interesting aspects of the library is the support for JSON types. Unfortunately, by default, the library will not pick up any Jackson configuration or custom serializers defined in your Spring Boot project. This blog post will show how to configure things so the JSON related configuration of…
In TodoMVC with Spring Boot and Thymeleaf , we implemented a TodoMVC clone using Spring MVC and Thymeleaf. In such a setup, each action triggers a page refresh. While this works just fine, you might want to give a more Single Page Application (SPA) spice to the experience and avoid page refreshes. This blog post will show how to use HTMX to accomplish this.
In Part 2 , we implemented completion and deletion of todo items. In this last part of the 3-part series, we’ll finish the implementation of our TodoMVC clone.
In Part 1 , we implemented TodoMVC using Spring Boot and Thymeleaf. The application already allows to add todo items and show them. We will continue in this part with completing items and deleting them.
The TodoMVC project has implementations of a simple todo list application for many different frontend frameworks. The goal is that a Single Page Application is implemented in a varity of technologies to be able to compare them. I wanted to stretch the concept a bit and create a Spring Boot backend with Thymeleaf server-side rendered HTML page just to see how that could work and how it would affect…
Iteration in Thymeleaf templates is done using th:each . But combining it with fragments can yield some surprising results. This blog post shows an overview of what can happen and common pitfalls to watch out for.
There is a new version 1.6.0 of the Error Handling Spring Boot Starter . A lot of new things have been added since I lasted blogged about version 1.2.0 of this library , so it is time for a round-up to show the new goodies.