How should I be declaring and exporting modules?

2019-02-22 09:54发布

问题:

I'm using the secure and crud modules with my app, and I've added them to application.conf as described in the tutorial. However, when I start my app, it generates a warning:

Declaring modules in application.conf is deprecated. Use dependencies.yml instead. (module.crud)

The modules then work while in dev mode, but when I deploy to my server (with play war etc), I get this:

13:55:40,662 WARN ~ Declaring modules in application.conf is deprecated. Use dependencies.yml instead (module.crud)

13:55:40,662 ERROR ~ Module crud will not be loaded because /var/lib/apache-tomcat-6.0.32/webapps/pat/WEB-INF/modules/crud does not exist

So, two questions: why aren't my modules getting exported, and how do I declare them in dependencies.yml? I've looked at the dependency page in the docs, and I admit that I don't really get what's going on there.

Thanks!

回答1:

The easiest way to set up modules in play 1.2+ is to use the --with keyword when you create your app.

For example

play new myapp --with crud,secure 

The output of the generated dependencies.yml is

# Application dependencies

require:
    - play
    - play -> secure
    - play -> crud


回答2:

OK, solved it. I added

- play -> crud
- play -> secure

to dependencies.yml, and deleted the relevant lines in application.conf. Then I ran play dependencies to copy the modules into my app. Play starts without any warnings, and the modules export to the WAR file correctly. I hope this helps people!