Posts

Showing posts from January, 2019

Recursively Move a Directory

recursively-move-a-directory This article shows one effective implementation that follows the Visitor Pattern to recursively move a directory using Java NIO library. public static void move ( Path source , Path target ) throws IOException { class FileMover extends SimpleFileVisitor < Path > { private Path source ; private Path target ; private FileMover ( Path source , Path target ) { this . source = source ; this . target = target ; } @Override public FileVisitResult visitFile ( final Path file , final BasicFileAttributes attrs ) throws IOException { Path newFile = target . resolve ( source . relativize ( file ) ) ; Files . move ( file , newFile , StandardCopyOption . REPLACE_EXISTING ) ; return FileVisitResult . CONTINUE ; } @Override public FileVisitResult pre

Creating a Library Project for Spring Boot

creating-a-library-project-for-spring-boot This article introduces the key points when creating a library for spring boot project. It could be common that over the years you have created a number of services that could be reused by other spring projects. It then makes sense to make the reusable modules such as a library and install it in your local repository for later use. Here are the key points to consider when building a spring boot library. release version build plugin dependency injection autoconfigurations Release Version To guarantee spring boot works the way you expect, it is recommended to keep update the release versions of the library so that it supports some versions of the spring boot minor version. A good practice is to monitor change spring boot changelog and see if there are any conflicting dependencies that are used in the library project. If there is, introduce a new version to resolve the conflict. Build Plugin If the projects refere