Java Web Application. Spring Boot. Locating Images

倾然丶 夕夏残阳落幕 提交于 2019-12-01 23:00:22

问题


I've recently solved a problem of locating images in this community. You can look here.

However, one answer said:

Your app is a Spring Boot app. I think that you can also try to use the facilities provided by Spring Boot for serving static content. Anyway, you are doing it right now because you are using webjars for css and js libs!!! Be consistent with the tech that you are using.

This means, it's recommendable to locate the images files in /src/main/resources and not in /src/main/webapp.

How could i use the facilites that Spring Boot provides me?

Thanks


回答1:


Spring Boot automatically configures production-ready settings and adds beans to your Spring project based on some dependencies that are declared in your maven/gradle build file. As long as you follow the conventions, then you do not have to do so much configuration -- "convention over configuration". For example, one convention is to load your images and static files in the resource classpath. Refer to the documentation: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/



来源:https://stackoverflow.com/questions/32798972/java-web-application-spring-boot-locating-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!