A more frequently occurring problem might be the need for using the same model in different applications. A simple solution is to make the model layer a module itself.
The source code of the example is available at examples/chapter5/module-model
.
So, create an application and a module:
play new app01 play new-module my-module-model
Change the dependencies.yml
to include the module:
require: - play - modelModules -> my-module-model repositories: - playmodelModules: type: local artifact: "/path/to/my-module-model/" contains: - modelModules -> *
If you just created your application like the one that we just saw, do not forget to add a database connection in your application configuration. For testing purposes use the in memory database via db=mem
.
Put a User model into your module at my-module-model/app/models/User.java
:
@Entity public class User extends Model { public String...