Articles of 2014

Maven Plugins To Build Frontend for Spring Boot Project

Update 12/2017: With all due respect to my Allegro buddies, there are more popular plugins for this.

To have front-end build during Maven build cycle has many advantages. Some time ago I wrote about integrating front-end build process into Maven lifecycle, by mostly writing an Ant script installing and running Grunt, and hooking it into Maven.

Static Resources in Spring 4.1

Update 12/2017: Maybe just use Spring Boot, it has all those things adjustable via application.properties.

There are some new features in Spring 4.1 that allow better handling of static resources in web applications. I'm going to take a look at them, and show an application based on Spring Boot that makes use of them.

Few Recommendations on Logging

Maybe it's basic, but still, sometimes some suboptimal usage of logger can be seen. There also is/was a notion that Java applications tend to overuse logging. That may or not be true, but using the logger properly should have minimal performance implications on the application. This one is to give you few recommendations for logging things in Java, based on my experience. Feel free to disagree in comments.

Spring Boot Security Application

Update 12/2017: It will need an update/rewrite since Spring Security 5 is coming.

Spring Security had some opinions of being complicated to use. Well, of course it's quite complicated when you look at it, as its scope covers a lot of use-cases. Thing is that, truly in a Spring spirit, you don't have to use every feature there is at once for the use-case you are having. In fact, when you start cherry-picking and back it with Spring Boot, it doesn't appear so complicated anymore.

Database Connection Pooling With BoneCP in Spring Boot Application

Update 12/2017: Time passed and support for db connection pooling was build into Spring Boot. HikariCP is used by default. BoneCP is RIP.

In the following article I'll try show you how to set up a database connection pool with BoneCP and integrate it to the Spring Boot application. The database will be MySQL, and the source code for this article is based upon the source code of Spring Boot MVC application from one of the previous posts. It's recommended to get familiar with this for the people new to Spring Boot.

Developing a RESTful Web Service Using Spring Boot

Update 12/2017: Sweet, but could use an updated version. The principles seem to stand though.

I'm really impressed with Spring Boot. Its main goal is to take away most of this boilerplate configuration that was needed before and to replace it with some sensible defaults. One might say it's taking the control away from the developer and giving it to the army of fairies. That's probably right, but in this case the fairies are here to help, and moreover they can easily be cast away from doing particular thing. It's just a matter of doing it yourself as before, and thanks to @ConditionalOn... behaviour Spring Boot's auto configuration will not fire up.

In the following article I will explore the way of employing Spring Boot to create a very basic, restful web service. As usual the source code can be found here on GitHub to play around.

Building Frontend as a Part of Maven Build Lifecycle

Update 12/2017: Nowadays just use a plugin. For Maven I could recommend frontend-maven-plugin, Gradle has gradle-frontend-plugin, or just use plain Node plugin like gradle-node-plugin and do the rest with Node scripts.

Thinking about the nature of things we can sometimes notice that a web application, depending of course on the level of sophistication, has in fact dualist nature when it comes down to its ontology. Having too vivid imagination we can relate it to Plato's duality of soul and body, which in case of web application can be a metaphor. As it is so that from the nature of web app we can derive a backend part, powered for example by a Java app, and a front end, where the use of JavaScript is dominant. The backend is soul, powering the body, but the body is what people see.

Both must be functional, both are equally important (ok, Plato would have disagreed with that, so let's leave the metaphor here), and they deserve the proper build process. It is very common though that often the front-end part is mistreated or ignored.

Spring Boot MVC application

Update 12/2017: Also could use an update.

In the last article I showed how the RESTful web service could be implemented using Spring Boot. In the following I'll make a more classical MVC application out of it, meaning real and pure, CSS-less, HTML form eye-candy.

Since there is not much difference between this and previous RESTful app, I'll focus only on what needs to be changed. And as usual, there is a source code for you to play around on GitHub, and if you want to follow the changes step-by-step, here's the source code for the RESTful web service from the previous article.