加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 如何将WebJars添加到我的Play应用程序?

发布时间:2020-12-16 19:14:56 所属栏目:安全 来源:网络整理
导读:为了在我的Play应用程序中使用WebJars,我添加了以下路线 GET /webjars/*file controllers.WebJarAssets.at(file) 在我的scala模板中,我添加了以下行: link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap.min.css"))'
为了在我的Play应用程序中使用WebJars,我添加了以下路线

GET     /webjars/*file              controllers.WebJarAssets.at(file)

在我的scala模板中,我添加了以下行:

<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap.min.css"))'>
<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap-theme.min.css"))'>

当我打开应用程序时,css文件被完美加载.但是一旦我运行了激活器eclipse,我就会收到以下编译错误:

[info] Compiling 4 Scala sources and 2 Java sources to /Users/d135-1r43/play/blog/target/scala-2.11/classes...
[error] /Users/d135-1r43/play/blog/conf/routes:10: object WebJarAssets is not a member of package controllers
[error] GET     /webjars/*file              controllers.WebJarAssets.at(file)
[error] /Users/d135-1r43/play/blog/conf/routes:10: object WebJarAssets is not a member of package controllers
[error] GET     /webjars/*file              controllers.WebJarAssets.at(file)
[error] /Users/d135-1r43/play/blog/app/views/main.scala.html:8: not found: value WebJarAssets
[error]         <link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap.min.css"))'>
[error]                                                              ^
[error] /Users/d135-1r43/play/blog/app/views/main.scala.html:9: not found: value WebJarAssets
[error]         <link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap-theme.min.css"))'>
[error]                                                              ^
[error] four errors found
[error] (compile:compile) Compilation failed
[error] Could not create Eclipse project files:
[error] Error evaluating task 'dependencyClasspath': error

知道这里发生了什么吗?我需要在classpath中添加一些东西吗?

解决方法

我遇到了同样的错误,在build.sbt文件中添加以下行解决了这个问题.

libraryDependencies += “org.webjars” %% “webjars-play” % “2.4.0”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读