本文介绍了Grails 3 - 获取服务中的资产路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我需要在Grails 3服务中获取位于 assets / schemas / resource.json 中的静态资源的路径。

I need to get the path of a static resource located in assets/schemas/resource.json in a Grails 3 service.

目前它被定义为

At the moment it is defined as

private final String SCHEMA = 'grails-app/assets/schemas/resource.json',

对于开发环境,但当然不适用于生产(因为它位于< app_root> /assets/resource.json

which is fine for development environment, but of course not for production (as it would be located in <app_root>/assets/resource.json.

我试图在我的案例中搜索如何利用Asset Pipeline,但到现在为止我真的不知道:P

I tried to search how to exploit the Asset Pipeline in my case, but up to now I really have no idea :P


推荐答案

它包含在文档中。

在控制器或服务中,注入 assetResourceLocator 并使用 assetResourc eLocator.findAssetForURI()

In a controller or service, inject the assetResourceLocator and use assetResourceLocator.findAssetForURI()

这篇关于Grails 3 - 获取服务中的资产路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:41