#!/usr/bin/env bash # Starts the real Boot application with three different profiles and captures what a developer # actually sees: the "APPLICATION FAILED TO START" report for a circular dependency, and the same # application starting once spring.main.allow-circular-references is switched on. set -euo pipefail cd "$(dirname "$0")/.." mkdir -p output JAR=$(ls target/core-di-*.jar | head -1) # Drops JAVA_TOOL_OPTIONS noise, machine-specific paths, timestamps and PIDs so reruns diff cleanly. strip() { grep -v -E '^Picked up JAVA_TOOL_OPTIONS' \ | sed -E 's#jar:nested:[^ ]*/target/#jar:nested:target/#; s#^[0-9T:.+-]+ (ERROR|WARN|INFO) [0-9]+ --- \[core-di\] \[[^]]*\] #\1 --- #' \ || true } { echo "# Boot start-up failure for a constructor cycle: --spring.profiles.active=ctor-cycle" echo java -jar "$JAR" --spring.profiles.active=ctor-cycle --spring.main.banner-mode=off --logging.level.root=ERROR 2>&1 | strip || true } > output/19-boot-failure-analysis-ctor-cycle.txt { echo "# Boot start-up failure for a field-injection cycle: --spring.profiles.active=field-cycle" echo java -jar "$JAR" --spring.profiles.active=field-cycle --spring.main.banner-mode=off --logging.level.root=ERROR 2>&1 | strip || true } > output/20-boot-failure-analysis-field-cycle.txt { echo "# Same field cycle with --spring.main.allow-circular-references=true" echo java -jar "$JAR" --spring.profiles.active=field-cycle --spring.main.allow-circular-references=true \ --spring.main.banner-mode=off --logging.level.root=WARN 2>&1 | strip } > output/21-boot-allow-circular-references.txt { echo "# @Lazy on one constructor parameter: --spring.profiles.active=lazy-cycle" echo java -jar "$JAR" --spring.profiles.active=lazy-cycle --spring.main.banner-mode=off --logging.level.root=WARN 2>&1 | strip } > output/22-boot-lazy-cycle.txt cat output/19-*.txt output/20-*.txt output/21-*.txt output/22-*.txt