sxz
sxz

Reputation: 153

How do I place files on the classpath?

I'm trying to implement a custom view in Spring-Boot-Admin. The documentation states "The JavaScript-Bundle and CSS-Stylesheet must be placed on the classpath at /META-INF/spring-boot-admin-server-ui/extensions/{name}/".

I think I've got the JS and CSS stuff, but where exactly do I have to put them now in my Spring Boot application? This is probably really simple but I don't understand it.

Upvotes: 0

Views: 278

Answers (3)

Mickey84563
Mickey84563

Reputation: 21

Anything placed in src/main/resources will be placed in your classpath if you are using a tool like Maven/Gradle.

Depending on how you setup your project, you may need to create a fat jar in order for Spring Boot Admin to pick up the files. You can look at the contents of your jar to see if that is necessary. Some IDEs like IntellliJ will create a fat jar for when you run your project from the IDE, but the jars created for deployment are not fat jars.

Upvotes: 1

cameron1024
cameron1024

Reputation: 10196

https://docs.oracle.com/javase/tutorial/essential/environment/paths.html

This is the Oracle documentation on the classpath, and is essential reading for any Java developer.

If you are using Spring Boot, I assume you are also using Maven/Gradle or some equivalent. If you follow their standard project structure, src/main/resources will be on the classpath and you can put your js/css there.

However, before going further I strongly advise you to read the above article as it really is quite fundamental to how the Java language works.

Upvotes: 1

Daniel Jeney
Daniel Jeney

Reputation: 506

They should go to the 'resources/static' folder.

Upvotes: 1

Related Questions