有没有办法将资源文件夹中的文件添加到项目中? Spring Boot 3.3.1 和 Spring Security 6.0

问题描述 投票:0回答:1

我什么都试过了。也许有人有解决方案? 有没有办法将资源文件夹中的文件添加到项目中? Spring Boot 3.3.1 和 Spring Security 6.0。 没有什么对我有用。我需要使用资源文件夹中的图像。

spring-boot spring-security resources
1个回答
0
投票

您可以使用ResourceLoader:

  @Autowired
  private ResourceLoader resourceLoader;
  
  ...

  resourceLoader.getResource("classpath:my_image.png")

图像必须位于资源文件夹的根目录中。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.