Grails 2.3.7 和缓存资源插件,至少使用lesscss 资源不能正常工作。
缓存的插件返回一个错误,与此线程中描述的错误相同:
<dt>Class</dt><dd>java.lang.NullPointerException</dd><dt>Message</dt><dd>Cannot invoke method cache() on null object</dd></dl><h2>Around line 31 of <span class="filename">grails-app/resourceMappers/org/grails/plugin/cachedresources/HashAndCacheResourceMapper.groovy</span></h2>
<pre class="snippet"><code class="line"><span class="lineNumber">28:</span> if (log.debugEnabled) {</code><code class="line"><span class="lineNumber">29:</span> log.debug "Setting caching headers on ${req.requestURI
问题是 cacheHeadersService 没有在 cacheheaders 插件中注入或为空。
为了解决这个问题,我将 cached-resources-plugin 1.1 的内容从 target/work/plugins 复制到本地文件夹并添加了以下行:
grails.plugin.location.'cached-resources' = "../grailsplugins/cached-resources-1.1"
目的是自己修复这个错误。
然而,奇怪的是,当插件在本地使用时,注入 cacheHeadersService 的问题就消失了!
插件在本地使用与正常安装时有何不同?
也许这是一个加载器问题,现在缓存资源插件在声明服务之后加载,但仍然值得报告。
在 cache-resources 插件的 dependencies.groovy 中,它声明了依赖项:
compile ":cache-headers:1.0.4"
但显然它不会在插件之前加载,除非从本地目录加载,奇怪!
我也想知道,因为缓存资源插件声明了对 tomcat 的依赖:
build(":tomcat:$grailsVersion",
":release:2.0.3",
":rest-client-builder:1.0.2") {
export = false
}
需要tomcat吗?尝试在主应用程序中更改为 Jetty,构建过程失败,说在存储库中找不到 tomcat。
build ":jetty:2.0.3"// ":tomcat:7.0.52.1"
我刚刚也发现了这些类似的问题: