Cannot find router.Routes in play 2.5.2 scala compile time dependency injection

1,548 views
Skip to first unread message

Saurabh Agrawal

unread,
Jun 7, 2016, 6:07:32 PM6/7/16
to play-framework
Hi,

I am trying compile time dependency injection in scala following the documentation below:

I wrote an AppComponents class which extends BuiltInComponentsFromContext like so:
class AppComponents(context: Context) extends BuiltInComponentsFromContext(context) {
 
  // Bunch of lazy vals here

lazy val myController = new MyController

override def
router = Routes(myController)

When I try compiling my app, it throws an error:

[error] /Users/xyz/work/git-repos/myapp/app/AppLoader.scala:66: not found: value Routes

[error]   override def router = Routes(myController)


All the documentation on internet says exactly the same thing that I have in my code, yet it doesn't work. Please help.


Thanks


Greg Methvin

unread,
Jun 7, 2016, 7:15:04 PM6/7/16
to play-framework
What are your imports? Typically you want to use router.Routes. See the example here: https://github.com/playframework/play-macwire-di/blob/master/app/GreetingApplicationLoader.scala

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/2f7aba7c-5111-45cf-8599-7f8f92194fb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Senior Software Engineer

Saurabh Agrawal

unread,
Jun 8, 2016, 4:38:48 AM6/8/16
to play-framework
Thanks Greg. I missed play.api._ in the imports. The app compiles fine now although Intellij Idea Cannot Find Symbol routes in  "import router.Routes".

Ronan Michaux

unread,
Jun 8, 2016, 11:16:24 AM6/8/16
to play-framework
I'am trying to use compile time dependency injection with MacWire and I had the same problem.

The file is generated under : target/scala-2.11/routes/main/router/Routes.scala

I add import router.Routes

Intellij compilation and sbt ~run both fails.

Then I do :
  1. exit Intellij.
  2. sbt clean
  3. sbt ~run

And now it works, strange !!

I hope it will helps...

Regards,
Ronan.
Reply all
Reply to author
Forward
0 new messages