Reputation: 17724
Hi I try to integrate play framework (current) 2.3.7 with Bootstrap 3:
sbt file:
libraryDependencies ++= Seq(
"org.webjars" %% "webjars-play" % "2.3.0-2",
"org.webjars" % "bootstrap" % "3.1.1-2"
)
html
<body>
<!-- Latest compiled and minified CSS -->
<link rel='stylesheet' href='@routes.Assets.at(WebJarAssets.locate("css/bootstrap.min.css"))'>
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Messages</a></li>
</ul>
Only throws this error: [MultipleMatchesException: Multiple matches found for css/bootstrap.min.css. Please provide a more specific path, for example by including a version number.]
a different try (which should have worked on earlier 2.3 versions): http://www.webjars.org/documentation
<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap.min.css"))'>
<script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets.locate("jquery.min.js"))'></script>
But Play only tells me that the web jar assets controller is not available
value WebJarAssets is not a member of object controllers.routes
Upvotes: 1
Views: 2798
Reputation: 1066
In my case I got the error:
value WebJarAssets is not a member of object controllers.routes
even though I had added
GET /webjars/*file controllers.WebJarAssets.at(file)
to the routes file.
sbt clean
did not help. I ended up with git clean -f -d -x
which removes everything not tracked by git. Then it compiled.
Upvotes: 2
Reputation: 17724
You simply use the Assets controller to access WebJars, they are extracted by Play automatically to the target/lib folder. You can refer to them via @routes.Assets.at(“lib/bootstrap/css/bootstrap.css”).
Upvotes: 1
Reputation: 2242
Do you have an entry in your routes file for the WebJarAssets controller? Something like this:
GET /webjars/*file controllers.WebJarAssets.at(file)
Upvotes: 3