Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add WebJars to my Play app?

In order to use WebJars in my Play app I've added the following route

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

In my scala template I've added the following lines:

<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"))'>

When I open the app, the css files are perfectly loaded. But as soon as I run activator eclipse, I get the following compilation error:

[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

Any idea what happened here? Do I need to add something to my classpath?

like image 349
d135-1r43 Avatar asked Dec 19 '14 23:12

d135-1r43


1 Answers

I have faced the same error, adding following line in my build.sbt file solved the issue.

libraryDependencies += "org.webjars" %% "webjars-play" % "2.4.0"

like image 67
Vinay Avatar answered Sep 30 '22 07:09

Vinay