Spring Boot : how to show actual classpath on startup or at runtime?

Viewed 8103

Is there a way to show Spring Boot actual classpath?

I am using STS to start my app and it reports that class XYZ is missing. Yet I checked my pom.xml and the dependency it self, and I can see the .class file.

I would like to show what is the real runtime classpath.

I used this (https://www.mkyong.com/java/how-to-print-out-the-current-project-classpath/), but I was looking for a solution that does not involve changing my app source code. A debug startup option type of thing. Actuator maybe. Whatever :)

Thanks

2 Answers

The classpath depends on the class loaders in use. For example Servlet Containers like Tomcat can load classes from multiple places e.g. shared lib directory or WAR archives. Spring Boot often repackages regular JAR to make it runnable by applying a custom layout. Without checking the class loaders there is really no way to tell what is part of the class path.

It's exactly what you said, debug option:

mvn spring-boot:run --debug

Related