Donnerstag, 14. März 2019

If there is no Link, it does not exist

Auf der JAX 2018 haben wir dem Talk "DevOps @ GitHub Speed" gelauscht. Der Vortrag ist in der Zwischenzeit nun auch bei YouTube "DevOps @ GitHub Speed" zu finden und man kann da als Entwickler, Scrum Master, PO oder auch jede andere Rolle eines Softwareunternehmens eine Menge lernen.
Einen Aspekt möchte ich besonders empfehlen, den ich auch versuche bei meiner Arbeit anzuwenden und zu verbreiten ist:

If there is no Link, it does not exist

Die Argumentation und was damit genau gemeint ist kann man sich in dem Video ab Minute 24:00 anschauen. Im groben Zusammengefasst ist damit gemeint:

Entscheidungen sind irrelevant, wenn sie nicht per Link für alle auffindbar sind

Beispiel: Entscheidungen, die ausschließlich per E-Mail dokumentiert sind, sind nur in den E-Mail-Postfächern der Mitarbeiter auffindbar, die an dem Mail-Verkehr beteiligt waren. Neue Mitarbeiter können diese nicht einsehen.
Gleiches gilt meines Erachtens auch für die Entscheidungsfindung - also wie es zu der Entscheidung gekommen ist. Wie oft habe ich schon erlebt, dass wir eine dokumentierte Entscheidung gefunden haben, diese gerne hinterfragen wollten, wir aber nicht wussten, warum diese Entscheidung so getroffen wurde und auch die beteiligten Personen dies nicht mehr wussten.

Start another main class within a Spring Boot jar

When you build your Spring Boot application with Maven and package it as a jar file you will start it via java -jar yourApp.jar. This will start the application with the class which is annotated with @SpringBootApplication. But what if there is another main-class you sometimes want to start?


When you normally work with Java you would do something like this:
java -classpath "yourApp.jar" your.domain.AnotherMainClass
But this will not work and you get this output instead:
Error: Could not find or load main class your.domain.AnotherMainClass

So there is something different than in normal Java jars.


Having a look into the META-INF\MANIFEST.MF within the jar shows that org.springframework.boot.loader.JarLauncher is defined there as Main-Class. After searching a while for that problem and with the information of the JarLauncher I was able to find this page https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html which defines a PropertiesLauncher that is able to launch another main class when defining it with the property loader.main.

So finally this worked for me:
java -classpath "yourApp.jar" -Dloader.main=your.domain.AnotherMainClass org.springframework.boot.loader.PropertiesLauncher