Reputation: 704
I'm having a huge problem showing an image uploaded in Spring Boot, problem is that the first time I upload it, the path is perfectly fine and everything is good but image not displaying, when i restart the server the image shows.
I think it's because when starting the project it compiles into a .jar without the image, so before restarting the project the image don't really exists.
I dont know how to fix this, not sure if possible.
The image is saved under static/img
Thank you alot
Upvotes: 1
Views: 2743
Reputation: 704
Finally i could slove this error, it seems that it was due IntellIj and a maven dependencies i wasn't using:
I did this:
In intell IJ
1) Help->Find Action... and type "Registry", in the dialog search for "automake" and enable the entry "compiler.automake.allow.when.app.running", close dialog
2) enable background compilation in Settings->Build, Execution, Deployment->Compiler "Make project automatically"
3) Open Spring Boot run config, you should get warning message if everything is configured correctly
4) Run your app, change your classes and static content on-the-fly
I also added this maven dependencies
org.springframework.boot
spring-boot-devtools
Upvotes: 0
Reputation: 12061
It sounds to me that you might be storing the image in webapps. If so:
Do not use the src/main/webapp directory if your application will be packaged as a jar. Although this directory is a common standard, it will only work with war packaging and it will be silently ignored by most build tools if you generate a jar.
I am assuming when you put this on your server it is a war file so the above does not matter.
Upvotes: 2