Created
March 23, 2013 23:40
-
-
Save zacker330/5229796 to your computer and use it in GitHub Desktop.
在app的根目录下新一个Global类继承自GlobalSettings。
这样,可以覆盖GlobalSettings类中的方法,以达到修改应用程序的行为:包括启动,停止等
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| 在app的根目录下新一个Global类继承自GlobalSettings。 | |
| 这样,可以覆盖GlobalSettings类中的方法,以达到修改应用程序的行为:包括启动,停止等 | |
| **/ | |
| import play.*; | |
| import play.libs.*; | |
| import com.avaje.ebean.Ebean; | |
| import models.*; | |
| import java.util.*; | |
| public class Global extends GlobalSettings { | |
| @Override | |
| public void onStart(Application app) { | |
| // Check if the database is empty | |
| if (User.find.findRowCount() == 0) { | |
| Ebean.save((List) Yaml.load("initial-data.yml")); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment