Relentless Coding

A Developer’s Blog

  • Spring Basics Wiring Beans With Xml Configuration

    If you have to work with legacy Spring applications, chances are you will have to know how XML-based configuration works. Although Java configuration is preferred for new applications, sometimes you just don’t have a choice, so you’d better be comfortable with it.

    Read more…
  • Quick Vim Tip: Change Text Between White Space

    private List<String> strings;
    

    When the cursor is on the S of String, use ciW to delete List<String> and start insert. Obviously, you can use any other command with that movement, for example yank the text (yiW) or delete it (diW).

    Read more…
  • Spring Basics Wiring and Injecting Beans With Java Configuration

    For new projects, Java configuration is preferred over XML-based configuration. In this post, we’re going to look at how to configure Spring with configuration in Java, instead of the traditional XML.

    Read more…
  • Use Vidir to Quickly Edit Filenames in Your Editor

    If you have installed moreutils (see below), you can type vidir to open up the current working directory in your $EDITOR. You can use all the power of your editor to edit and/or delete filenames and directories. Editing a line will rename the file or directory, deleting a line will remove the file or directory.

    Read more…
  • Use Pandoc With Pygments to Highlight Source Code

    I am someone who has JavaScript disabled by default in his browser (I use uMatrix in Firefox for that). Only when I trust a site and I need to use functionality that truly depends on JavaScript will I turn it on. This hopefully protects me from most of the known and unknown bad stuff out there on the internet. It also makes me appreciate people who go through the trouble of making their webpages work without JavaScript.

    Read more…
  • Remove All Files Except a Few in Bash

    How can remove most of the files in a directory in Bash?

    Read more…
  • Tomcat7 Maven Plugin Invalid Byte Tag in Constant Pool 19

    I use tomcat7-maven-plugin to spin up a Tomcat 7 container where I can run my web application. When I added dependencies for log4j2 (version 2.11.0) to my project, I got the error:

    org.apache.tomcat.util.bcel.classfile.ClassFormatException:
    Invalid byte tag in constant pool: 19
    

    Apparently, log4j2 is a multi-release jar and older versions of Tomcat can’t handle that. So I needed to upgrade my Tomcat maven plugin.

    Read more…
  • How to Write a Custom Appender in Log4j2

    Ever wanted to test whether a log statement is triggered? Or whether the format is the way you want? In this post, we’re going to create a custom log appender so we can be sure logging is behaving the way we expect.

    Read more…
  • Unit Test Log4j2 Log Output

    Sometimes you want to test if certain log output gets generated when certain events happen in your application. Here is how I unit test that using log4j2 (version 2.11.0).

    Read more…
  • JMockit Fakes

    If you are working with microservices, you may find that you are having a lot of dependencies on other services. If you want your tests to be autonomous, that is, running in isolation of those dependencies, you can either use a tool like WireMock, or you can use a mocking framework.

    Recently, I came across JMockit, a mocking framework for Java.

    Read more…