Deploy Playframework application on Heroku
- 下載 Heroku Clinet Command line tools http://toolbelt.herokuapp.com/windows/download
- 在你的 playframework app 下建立 git repo,並且 add file and commit:
This file contains 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 charactersgit init git add app conf lib public test git commit -m init - 在Heroku上建立一個新的app:This file contains 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
heroku create -s cedar -
將project push到Heroku上:This file contains 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
git push heroku master
設定 Heroku 上的MySQL
- 這裡使用的是 ClearDB MySQL Database,首先要先去把這個 add-on 給啟用:
-
接著,在 play app 中的 application.conf 中,設定資料庫的連線部分:This file contains 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
%prod.db=${CLEARDB_DATABASE_URL} %prod.jpa.dialect=org.hibernate.dialect.MySQLDialect %prod.jpa.ddl=update - 接著重新把專案 push 到 Heroku 上(上述的2~4步驟),應該就會正確吃到MySQL了!
0 意見:
張貼留言