Java Web应用程序。春季启动。找到图像 [英] Java Web Application. Spring Boot. Locating Images

查看:188
本文介绍了Java Web应用程序。春季启动。找到图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近解决了在这个社区中定位图片的问题。您可以在此处查看

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

然而,一个答案说:


您的应用程序是一个Spring Boot应用程序。我认为你也可以尝试使用Spring Boot提供的工具来提供静态内容。无论如何,你现在正在做,因为你正在使用webjars for css和js libs!与您正在使用的技术保持一致。

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.

这意味着,建议在中找到图像文件/ src / main / resources 而不是 / src / main / webapp

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

我怎么能使用Spring Boot为我提供的设施?

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

谢谢

推荐答案

Spring Boot自动配置生产就绪设置,并根据maven / gradle构建文件中声明的一些依赖项向Spring项目添加bean。只要遵循惯例,那么您就不必进行如此多的配置 - 约定优于配置。例如,一种约定是在资源类路径中加载图像和静态文件。请参阅文档: http://docs.spring.io/spring -boot / docs / current / reference / htmlsingle /

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/

这篇关于Java Web应用程序。春季启动。找到图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆