Skip to content

Instantly share code, notes, and snippets.

@dehidehidehi
Created October 26, 2023 15:44
Show Gist options
  • Save dehidehidehi/ad34b997ba1b1470157ce4cc72b80547 to your computer and use it in GitHub Desktop.
Save dehidehidehi/ad34b997ba1b1470157ce4cc72b80547 to your computer and use it in GitHub Desktop.
JShell bootstrap code for loading full application classpath with Maven.
#!/bin/bash
# Compile if needed.
#mvn package -DskipTests
# Remove Maven logs and trim leading and trailing whitespaces with xargs.
cp=$(mvn -q dependency:build-classpath \
-DincludeTypes=jar \
-Dmdep.outputFile=/dev/stderr \
2>&1 >/dev/null | grep -v -E '(DEBUG|INFO|WARNING)' | xargs)
export CLASSPATH=$cp":target/classes"
# Specify Java code to run at start of JShell.
startUpJavaBootstrap="./bootstrap.jsh"
# Start JShell with full reflexion capabilities.
jshell \
-J--add-opens=java.base/java.lang=ALL-UNNAMED \
-J--illegal-access=permit \
-start DEFAULT \
-start PRINTING \
-start $startUpJavaBootstrap
@dehidehidehi
Copy link
Author

public static ConfigurableApplicationContext main() {
return SpringApplication.run(DemoApplication.class);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment