Play app with dependencies on 3 other play apps

2019-08-17 03:31发布

问题:

I am running a play app, this app has dependencies on 3 other play apps, i.e. the first play app has 3 dependencies in build.sbt.

Now of course all these 4 apps have their own route.conf file.

The thing is when I start the first app, APIs for one of the jars start working instead of the app that i started. What I mean is that all the API urls for the first app is invalid and doesn't open while APIs of one of the jars that I added as a dependency starts working.

Is there a way to stop this from happening and most importantly why is this happening?

Sorry, but the info is not available in the docs or someplace else.

Thanks!

回答1:

You must be sure that the routes are unique.

What I did was to name routes files. To have only one with the name routes.

In this one I revered the other ones:

# Page.
GET        /wizard/:wizard/:user        server.WizardController.wizardPage(wizard: String, user: String)

# Reuse the routes from the ADAPTERS project
->         /                            adapters.Routes

Here is my example: https://github.com/pme123/scala-adapters-wizard

In your case it is the other way around (one routes forwards to the other routes for different sub-paths)

# Page.
->        /app2   app2.Routes   
->        /app3   app3.Routes   
->        /app4   app4.Routes   

# Routes from app1
GET         /doIt                            controller.doIt()
...

And that you run the app you want. Like sbt app1/run. This is necessary if app1 is not the default project - see the documentation.