I have a SpringBoot App which serves some static content.
Let’s say I run it on port 8080
- I can see for example the file index.html if I go to http://localhost:8080/index.html
- I can see for example the file test.json if I go to http://localhost:8080/test.json
Now inside the SpringBoot App itself I want to access the file “test.json” that I serve. How do I go and access it ?
I could send my self an HTTP GET at http://localhost:8080/test.json and I would get it but it seems silly since I am the one who serves it…
So what’s the solution ?
Note: I can’t just traverse the classpath for the resource “test.json” because the resources I serve are driven by the property “spring.web.resources.static-locations” so I could have test.json in an external folder