Monday 5 December 2022

Migrating a project from Java 11 to Java 17

Java 17 is new LTS version and it make sense to migrate existing projects to the new version. I will describe my specific case

Friday 11 September 2020

Generate settings-security.xml file for maven password encryption

 mvn --encrypt-master-password does not create a file security-settings.xml

  1. Use the command mvn --encrypt-master-password to generate a master password. Remember this password.
  2. Create a new file security-settings.xml in ${user.home}/.m2/. For example, on Mac OS X or Ubuntu as ~/.m2/settings-security.xml.

Write into this file:

<settingsSecurity>
  <master>OUTPUT OF THE COMMAND: mvn --encrypt-master-password</master>
</settingsSecurity>

e.g.:

<settingsSecurity>
  <master>{jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}</master>
</settingsSecurity>

After that the maven encrypt command works on the command line:

mvn --encrypt-password

As mentioned by khmarbaise, more detailed information can be found here: https://maven.apache.org/guides/mini/guide-encryption.html


source 

Monday 1 June 2020

Intellij Idea can't resolve generated class

It was really annoying issue, we had some maven plugin that generates classes from some schema, and for some reason Intellij Idea cant resolve this class. It just marks it with red. The reason was too big file size i've increased it like this:

# Maximum file size (kilobytes) IDE should provide code assistance for.
idea.max.intellisense.filesize=6000

# Maximum file size (kilobytes) IDE is able to open.
idea.max.content.load.filesize=6000

in Help > Edit Custom Properties

and then File > Restart & invalidate

Tuesday 28 April 2020

End-to-end tests with Spring and Test Containers

I've heard previously about test-containers but didn't have chance to read about it. Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

So basically it simplify you process of creating and maintaining end-to-end tests. You no need external containers you simple can run in on jenkins during your usual testing life cycle.

Two articles illustrate this approach with  Selenium and one more with WireMock

Sunday 26 April 2020

Micrometer - SLF4J but for metrics

Nice tool to try, Micrometer is - facade over the instrumentation clients for a number of popular monitoring systems. Currently, it supports the following monitoring systems: Atlas, Datadog, Graphite, Ganglia, Influx, JMX and Prometheus. More in tutorial

Syntaxis is simple and straightforward:

 Metrics.counter("objects.instance").increment();

Sunday 27 October 2019

Useful Java tools to try

java mission control - to monitor jvm

lincheck testing concurrent data structures

jmh - it is tool for microbenchmarking your code

debezium - tool to capture database changes (mongo, oracle...)