Showing posts from July, 2014

Spring boot JPA broken encoding on database when loaded from data.sql file

As covered in a previous article (here and here) spring-boot is a very useful framework when working on full enabled Spring projectsRecently I wasted some time with yet another encoding problem.. where all my accentuated and special characters where corrupted.I was using the data.sql convention that states that if a file named data.sql is found in the CLASSPATH spring will use this file to bootstrap the database, my SQL file was properly encoded in UTF-8 as well as my maven-resources-plugin however the data recovered from the database was corrupted (accents and special characters where broken) After reading a bit the documentation I found out that the source of the problem was at the moment of reading the SQL file that the encoding was causing trouble.. thankfully you can fix this one pretty easlily by changing one property value : spring.datasource.sqlScriptEncoding=UTF-8 spring-boot has a lot of useful properties that allow you to tune the framework which you can find here

Maven custom packaging with the assembly plugin

It's not uncommon to need a custom packaging or assembly for a given project for some reason or another, this can be accomplished in a certain number of ways Recently I needed an application to be packaged as the following structure : |- runnable-jar.jar |- lib |-- axis.jar |-- commons.logging.jar |- certificates |-- cacerts.jks |- config |-- |- logs The schema is pretty self-explanatory I needed a runnable JAR at the root of my dist folder with a few other folders such as config, logs, etc.One way to accomplish this with maven is to use maven-assembly-pluginThe Assembly Plugin for Maven is primarily intended to allow users to aggregate the project output along with its dependencies, modules, site documentation, and other files into a single distributable archive.Your project can build distribution assemblies easily, using one of the convenient, prefabricated assembly descriptors. These descriptors handle many common operations, such as pac…