我为此搜索了stackoverflow,发现了一些类似的引用但没有具体的解决方案......
我正在使用带有twitter-bootstrap:3.2.1插件的Grails 2.4.2,但在run-app期间遇到以下错误:
| Error 2014-07-26 11:51:48,592 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-fixtaglib.css
| Error 2014-07-26 11:51:48,668 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap.css
| Error 2014-07-26 11:51:48,725 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-theme.css
| Error 2014-07-26 11:51:48,778 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-alert.js
| Error 2014-07-26 11:51:48,807 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-affix.js
| Error 2014-07-26 11:51:48,837 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-dropdown.js
| Error 2014-07-26 11:51:48,860 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-modal.js
| Error 2014-07-26 11:51:48,888 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-popover.js
| Error 2014-07-26 11:51:48,907 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-scrollspy.js
| Error 2014-07-26 11:51:48,921 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-tab.js
| Error 2014-07-26 11:51:48,934 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-tooltip.js
| Error 2014-07-26 11:51:48,947 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-button.js
| Error 2014-07-26 11:51:48,959 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-carousel.js
| Error 2014-07-26 11:51:48,977 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-collapse.js
| Error 2014-07-26 11:51:48,996 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap-transition.js
| Error 2014-07-26 11:51:49,012 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/bootstrap.less
该插件的重点是简化资产管道并让插件将所有内容放在适当的位置。
我有BuildConfig.groovy设置来插入插件:
...
plugins {
// plugins for the build system only
build ":tomcat:7.0.54"
// plugins for the compile step
compile ":scaffolding:2.1.2"
//compile ':cache:1.1.7'
compile ":asset-pipeline:1.8.11"
compile ":twitter-bootstrap:3.2.1"
// plugins needed at runtime but not for compilation
//runtime ":hibernate4:4.3.5.4" // or ":hibernate:3.6.10.16"
//runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
runtime ":resources:1.2.8"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.7.4"
compile ":less-asset-pipeline:1.7.0"
//compile ":coffee-asset-pipeline:1.7.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
...
据我所知,我的GSP设置正确:
<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Task Master - Tasks</title>
<r:require module="jquery"/>
<r:require module="bootstrap-js"/>
<r:require module="bootstrap"/>
<r:layoutResources/>
</head>
<body class="container">
<h1>Task Master - Tasks</h1>
<r:layoutResources/>
</body>
</html>
我检查过,他们不在错误状态下属于/ assets。我看到有些人通过手动复制资产来攻击解决方案的地方,但那么插件是否有点?要么我错过了一些简单的东西,要么插件中有一个错误。有任何想法吗?感谢。
- 莱恩
答案 0 :(得分:4)
在Grails 2.4中,asset-pipeline是获取客户端静态资源的默认机制。在您的BuildConfig&#34;资产管道&#34;以及&#34;资源&#34; (使用2.4之前的默认机制)。我不确定,如果这个配置真的是你想要的,甚至可以用它。
只有资产管道的有效配置应为:
BuildConfig.groovy:
plugins {
compile ":asset-pipeline:1.8.11"
compile ":twitter-bootstrap:3.2.1"
runtime ":jquery:1.11.1"
}
的grails-app /视图/布局/ main.gsp:
<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Task Master - Tasks</title>
<asset:stylesheet href="application.css"/>
</head>
<body class="container">
<h1>Task Master - Tasks</h1>
<asset:javascript src="application.js"/>
</body>
</html>
grals应用内/资产/样式表/ application.css:
/*
*= require bootstrap
*= require_tree .
*/
grals应用内/资产/ JavaScript的/ application.js中:
//= require jquery
//= require bootstrap
//= require_tree .
有关详细信息,请参阅asset-pipeline plugin的文档以及twitter-bootstrap插件的文档。
我查了一下,因为错误状态
,他们不在/ assets下
这是事实,因为在您的应用程序中不会复制任何内容,而是资源存在于引导程序插件的assets directory中。 asset-pipeline插件扫描资产文件夹(或web-app文件夹的每个插件以实现兼容性)并将其组合在一起,因此在生成的战争中,所有资源都可用。