Tagged: spring-boot

SpringBoot + Thymeleaf + i18n (Internationalization)

Hello again. This week I had to study how to implement i18n in a Spring Boot + Thymeleaf CRM application I am developing. Spring Boot really makes it easy to setup but while I was searching about it on the Web I found a lot of misinformation and so I decided to make a post about it. As usual, you can find the complete project on Github: https://github.com/mtrojahn/springboot-thymeleaf-i18n. Let’s start by the pom.xml:

Application.groovy

As you can see, Application.groovy is pretty much the default for any Spring Boot application. I only changed @ComponentScan to lookup the package that...

Spring Boot / Thymeleaf: Fragments via Ajax

This is probably not the best approach and you guys can feel free to correct me in the comments section, but here is a simple tutorial on how I’m getting my fragments loaded via ajax. Same as before, the full project is on my Github: https://github.com/mtrojahn/spring-thymeleaf-fragments-from-ajax Let’s get to it: MyController.groovy

Very simple controller. Nothing special except for the fact it’s returning Thymeleaf fragmets from /resources/templates/fragments. As you probably noticed, for the sake of this example, each fragment is recieving it’s “content” from the controller. Here’s a fragment: frag1.html

Now the index.html

Each button has it’s event and is calling...

Spring-Boot / Websocket Example

It’s been a while! Project for this post: https://github.com/mtrojahn/spring-boot-websocket Recently I stumbled upon the need of using Websockets. I confess I know little about the subject and I hope this little tutorial can help you to get started. I’m making this post just because I tried to help here on StackOverflow and I thought I should just post it here as well. pom.xml

Application.class (nothing special here)

WebSocketConfiguration.class

PingPongController.class

This is the main thing. For this example I added a scheduled method that will periodically broadcast a message to all clients and another method that will just...

Integrating ZK Framework on a Spring Boot application

The complete project can be found here: https://github.com/mtrojahn/spring-boot-groovy-zk As you already know if you read my previous posts, I kinda decided to shift my focus to Groovy and I’m learning as I go. Feel free to correct me any time on the comments if you feel I’m doing something wrong or not optimal. In this post I’ll show how to integrate the ZK Framework on a Spring-Boot project just to output a “Hello World” message coming from an autowired bean just so we can check if everything is correctly wired. As usual, let’s start with the build.gradle file:

Ok,...

Spring-Boot / Groovy / MVC “Hello World” example

The complete project can be found here: https://github.com/mtrojahn/spring-boot-groovy-mvc-simple This is yet another very basic example. This time I’ll show how to create get a Web-MVC Spring-Boot project started. You will notice I take the no-XML approach and I’ll try to keep my examples as XML-free as they can be because it’s hard to find fresh documentation about it on the Web. So, let me start with the build.gradle file:

As you can see, no big changes from my previous example. Basically all you have to do is change spring-boot-starter to spring-boot-starter-web. Ok, now let’s have a look on the...

Spring-Boot / Groovy / Gradle “Hello World” application

The complete code for this project can be found here: https://github.com/mtrojahn/spring-boot-groovy-console-app Last weekend I was playing around with Gradle which I have never used before. The result is this very basic spring-boot project just to illustrate how I did it. Gradle isn’t that difficult but I had a few problems until I learn about the spring-boot-gradle-plugin and such. This is the build.gradle:

As you can see it’s fairly simple and way more organized than Maven in my opinion. The spring-boot-gradle-plugin is the key here. It provides all the version information for the dependencies and also adds a Gradle task...

Spring-boot / Maven simple “Hello World” application

The complete code for this application: https://github.com/mtrojahn/spring-boot-console-app In this example I’ll try to show how to create a simple console application to print out the traditional “Hello World” message using spring-boot on a Maven project. I’ll try to keep it as simple as possible for now and I’ll most likely use this code as base for new posts. Let’s start with the pom.xml file.

This is a simple console application so, for now, we only need “spring-boot-starter” as dependency. You can also notice that I included a few plugins. The most important for now is the spring-boot-maven-plugin which will...

%d bloggers like this: