springboot,ruoyi项目,在本地集成积木报表,方式:使用Pom引入的依赖。
本地启动积木报表一切正常,静态资源可以正常访问(application-dev.yml没有添加关于任何积木报表的配置)

但是发布到生产环境后,静态资源就404了(application-prod.yml没有添加关于任何积木报表的配置)

我需要在配置文件添加什么吗?
springboot,ruoyi项目,在本地集成积木报表,方式:使用Pom引入的依赖。
本地启动积木报表一切正常,静态资源可以正常访问(application-dev.yml没有添加关于任何积木报表的配置)


我需要在配置文件添加什么吗?
关注让 “紫雾凌寒” 来帮你回答,本回答结合 DeepSeek
如果还有问题,请评论或点击头像私信,如果有帮助到您, 请关注、采纳、点赞
application-dev.yml未添加积木报表相关配置。application-dev.yml中添加如下配置(假设积木报表静态资源根目录为/static/jimu-report):spring:
resources:
static-locations: classpath:/static/,classpath:/static/jimu-report/
pom.xml中关于资源过滤和打包的配置。例如:<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/jimu-report")
public class JimuReportController {
@GetMapping("/static/**")
@ResponseBody
public ModelAndView staticResource() {
// 这里可以根据实际情况返回正确的静态资源视图或内容
ModelAndView mv = new ModelAndView();
mv.setViewName("redirect:/static/jimu-report/your-static-resource-file");
return mv;
}
}
spring.resources.static-locations:spring.resources.static-locations:application-dev.yml中配置spring.resources.static-locations来尝试让Spring Boot正确映射积木报表的静态资源路径,这是较为常规和简单的方法。如果此方法不行,再考虑在控制器中手动处理静态资源请求,通过定制化的逻辑来确保积木报表静态资源能够被正确访问。在处理过程中,要注意检查依赖、资源打包以及路径的准确性等方面。 希望以上解答对您有所帮助。如果您有任何疑问,欢迎在评论区提出。