Posts tagged with Java

  • SDKMAN! on Windows

    Dec 7, 2019

    SDKMAN! manages multiple versions of Java related SDKs. In its homepage, it says it runs on any UNIX based platform, but I gave it a try on Windows and it works quite fine there too.

  • Testing null, empty, blank

    Sep 14, 2019

    In many cases, when you have a method that accepts a mandatory string parameter, you want to verify that the parameter contains a value that isn’t null, nor empty, not blank (i.e. consisting solely of whitespace characters). While writing the check is easy, testing it can be a bit annoying.

  • Optional files in Maven archetypes

    Sep 7, 2019

    This post shows how to create a Maven archetype that can conditionally include or exclude files while generating a project.

  • A CLI comparison of Java, JavaScript and Python

    Mar 16, 2019

    The inspiration for this post is the Python, Ruby, and Golang: A Command-Line Application Comparison published on Real Python.

  • clang-format as a git filter

    Jan 27, 2019

    clang-format is a tool that can format source code of C-like languages (C / C++ / Java / JavaScript / Objective-C / Protobuf). It supports various presets but it is also possible to fine tune its behavior with a configuration file named .clang-format. It has quite a lot configuration options.

  • YAML schema validation with Maven

    Nov 28, 2018

    Sometimes it feels we’re reinventing the wheel, but with different names. Back in the days, XML was the cool thing. We had XPath as a query language. We had XSLT to transform XML documents into different shapes. We had XSD to validate the schema of XML. We had code generation and validation. We could generate web service clients and servers with WSDL.

  • Troubleshooting SSL - missing /root/.postgresql/root.crt

    Nov 2, 2018

    I run into a problem today trying to connect to an Azure PostgreSQL database. The database enforces SSL connections (“SSL enforce status” = “ENABLED”).

  • Merging Swagger files

    Oct 28, 2018

    Consider the following scenario. You have a few microservices and they’re all developed independently: they don’t share code, they don’t share data and they don’t share schema. They’re all exposing their own REST API. To make things a bit simple, their API is defined in a swagger file.

  • Code coverage on integration tests?

    Aug 11, 2018

    Should you collect and measure code coverage on integration tests or only unit tests? In this post I’ll share some thoughts on this topic.

  • Using Spring Boot Actuators

    Jul 7, 2018

    Implementing Spring Boot actuators is not very difficult. In this post I’ll show what you can get for free, without adding any code.

  • Swagger and MapStruct

    Apr 29, 2018

    I’ve been working lately on a project with a few services (or microservices, if you like to play buzzword bingo). I wanted to share some thoughts on how using Swagger together with MapStruct can make things easier.

  • AssertJ cheatsheet

    Apr 22, 2018

    AssertJ is a an assertions library for unit tests in Java that is well worth considering. Here are some examples.

  • Using swagger code generator with maven

    Apr 21, 2018

    Following up the previous post about swagger, in this post I’m using the maven plugin version of swagger code generator.

  • Generate PNG barcode

    Apr 21, 2018

    How to generate PNG barcodes in Java using the zxing library:

  • Copy InputStream to OutputStream

    Apr 21, 2018

    To copy from a stream into a file:

  • Exclude class from JaCoCo coverage

    Apr 21, 2018

    JaCoCo’s exclude configuration works with classes, so the .class extension is relevant in specifying the path.

  • Building a REST API with Swagger and Spring Boot

    Apr 15, 2018

    In this post, I’ll be using Swagger to build a REST API with Java and Spring Boot. Swagger is an API framework. It uses a YAML-based language to define an API and it has a code generator that supports multiple languages.

  • Validate filename conventions with Maven Enforcer plugin

    Apr 17, 2017

    In this post I’m using the Maven Enforcer plugin to break the build when certain files don’t follow the expected naming convention. It’s always a good idea to take the time and implement these checks inside the build pipeline. The alternative is hoping that code reviewers will spot the problems, which is a manual, tedious and error prone approach. Automate all the things!

  • Debugging Docker with IntelliJ IDEA

    Mar 26, 2017

    In this post we’ll create a small Java application, run it inside a Docker container, and use IntelliJ IDEA to debug. This is a rather large post, so take your time.

  • Linting with Checkstyle

    Mar 12, 2017

    Code is going to be written once but read many times. A consistent coding style across the entire code base is important to increase readability and maintainability. Luckily, there are tools that can help to define and enforce such styling rules. From mere cosmetics up to nasty code smells, static code analysis can help increase the quality of your code. I wrote some posts on static code analysis in JavaScript a bit more than a year ago (which in the JavaScript world means the tools are now different, ESLint instead of JSCS/JSHint). In this post we’ll see the Checkstyle tool in the Java world, how to use it with TeamCity and IntelliJ and finally a few words about SonarQube.

  • Code Coverage with JaCoCo

    Mar 12, 2017

    Code Coverage is a useful set of metrics that show you how much of your code you’re impacting during testing. It doesn’t say much about the quality of your tests (you can read more in the old post What is code coverage?), but a 30% coverage is definitely worse than 90%. Let’s see how we can use JaCoCo to see our code coverage in the Java world. We’ll check a few options to use it, such as using it manually, using it within a CI, breaking the build with it, etc. The assumption is we’re working with a Maven project.

  • A quickstart Maven archetype for Java 8

    Feb 25, 2017

    As a Maven rookie, I often use the quickstart archetype from Maven when I want to create a new Maven project. Unfortunately, that archetype is a bit outdated, which means I have to tweak some details before I can actually use it. I guess I got a bit tired of this and I thought I could create my own archetype that is ready to use.

  • How to create a simple web app with maven

    Sep 18, 2016

    This post shows how to create a simple web application with maven. I have the relevant commits as well in GitHub for reference, in case you want to see in more details.

  • Maven Tips

    Jun 14, 2015

    I started using Maven at work recently. Being a newbie, I find myself googling constantly (even though the answer is always on StackOverflow) about basic things. For reference, these are my most needed actions so far:

This site uses third party cookies from Google Analytics and Google AdSense Accept and close popup