I'm using spring boot and storing my static content (html, css, etc.) as src/main/webapp
. I understand that this is not recommended, because it won't be stored in jar file (should be in /META-INF/resources/
, /resources/
, /static/
, /public/
). But my question is not about storing static content in jar.
This is project structure:
App
├──src
| └───main
| ├── java
| | └── ...
| ├── resources
| | └── (everything here will be in jar)
| └── webapp <- this won't be in jar
| └── ...
└ target
└───App.jar
When I'm trying to run jar from App
folder as java -jar target/App.jar
, spring boot finds static content and works fine. However running it from target
folder as java -jar App.jar
won't find static content.
How to run App.jar
from target folder and let spring boot find static content? Is it related to the classpath? I was trying to specify the classpath with -cp
option, but it doesn't work.