Playframewok 2.0 ã§ã®ç°å¢ãã¨ã®è¨å®ã®åæ¿æ¹æ³ã«ã¤ãã¦èãã¦ã
åå¿é²ã§ããã
ç¶ç¶çããªããªã¼æ°ããããããç°å¢ã«åããã¤ããªããããã¤ããã
éçºç°å¢ã¨ãæ¬çªç°å¢ã ã¨ãã§åãè¨å®ã使ã£ã¦ãããªãã¦ãã¨ã¯ãã¾ããæ®ã©ç¡ãã¨æãã¾ãã
DBã®æ¥ç¶å
ã¨ããå¤é¨ãµã¼ãã¹ã®URIã ã£ããã¨ãã
ãªã®ã§ãéçºã«ãããã¤ããæã¨æ¬çªã«ãããã¤ããæã§è¨å®æ
å ±ãåãæ¿ããå¿
è¦ãããããã§ãããããåãããã¢ããã¼ãã¨ãã¦ã¯ä»»æã®ç°å¢ç¨ã«ãã«ãããã¨ããã®ãããã¨æãã¾ãã*1
ã¤ã¾ã
build devel
ã¨ã
build prod
ã¿ãããªãã¨ããã¦ãããããã®ç°å¢ç¨ã®è¨å®ã§ãããããã®ç°å¢ç¨ã®ãã¤ããªãä½ãã¨ããã¢ããã¼ãã§ãã
ããããç¶ç¶çããªããªã¼ã¯ããè¨ã£ã¦ãã¾ãã
ãããããªç°å¢ã«ç°¡åã«ãããã¤ã§ããããã«ãªããåé¡ã®åãåããããããªããããã©ã®ç°å¢ã«ãããã¤ãããã«ãããããåããã¤ããªä½¿ããã
ãããªãã¨ãã¢ããªã±ã¼ã·ã§ã³æ¬ä½ã«ã¯è¨å®ã¸ã®ãã¤ã³ã¿ã ããè¨è¿°ãã¦ããã¦ãè¨å®ã¯å¥ã§ç®¡çããå¿
è¦ãããã¾ãã
Playframeworkã®å ´å
Playã¯è¨å®æ
å ±ãconfãã£ã¬ã¯ããªé
ä¸ã®application.confããèªã¿è¾¼ã¿ã¾ãã
Play 1.x ã®æ代ã«ã¯ãããã¤å
ã®ãµã¼ãã«ã¤ã³ã¹ãã¼ã«ããã¦ããPlayã«å¯¾ãã¦ä»»æã®ããã¬ã¼ã ã¯ã¼ã¯IDããæ¯ããã¨ãåºæ¥ãapplication.confå
ã®è¨å®ãã¼åã«ãã¬ã¼ã ã¯ã¼ã¯IDãå«ãããã¨ã§ãèªèº«ããããã¤ããã¦ããç°å¢*2ã«å¿ãã¦é¸æããè¨å®ãåãæ¿ããä»çµã¿ã§ããã
ããPlay 2.0 ããã¯ãã¬ã¼ã ã¯ã¼ã¯IDãå»æ¢ããã¦ãã¾ãã*3
ãããªãã¨åè¿°ããããä»»æç°å¢å°ç¨ã®ãã¤ããªããã«ãããããç¡ãâ¦ããã§ã¯ãªããPlayã¯ãµã¼ãèµ·åæã«å©ç¨ããconfãã¡ã¤ã«ã以ä¸ã®ããã«ã³ãã³ãã©ã¤ã³å¼æ°ã§æå®ãããã¨ãã§ãã¾ãã*4
# ã¯ã©ã¹ãã¹ããæ¢ã target/start -Dconfig.resource=devel.conf & # ã¯ã©ã¹ãã¹å¤ã®ãã¡ã¤ã«ã·ã¹ãã ããæ¢ã(絶対ãã¹) target/start -Dconfig.file=/path/to/devel.conf &
ãªã®ã§ããprod.confãããdevel.confãã¿ãããªç°å¢ãã¨ã®è¨å®ãã¡ã¤ã«ãä½ã£ã¦ããã¦ããµã¼ãèµ·åæã«æå®ããã®ãããããã§ãã
ãããããconfãã¡ã¤ã«åãç°å¢å¤æ°ã«è¨å®ãã¦ããã°ãèµ·åã¹ã¯ãªããã®ç°å¢ä¾åããªããªã£ã¦è¯ãæãã
export CONF=devel.conf target/start -Dconfig.resource=$CONF &
ã¡ãªã¿ã«
Playã®è¨å®ãã¡ã¤ã«ã¯
include "application.conf"
ã¨æ¸ããã¨ã«ãã£ã¦æå®ãããã¡ã¤ã«ã®æ å ±ãç¶æ¿*5ãããã¨ãã§ããã®ã§ãapplication.confã®å 容ãããã©ã«ãã¨ãã¦includeããç°å¢ãã¨ã«å·®ç°ãããé¨åãä¸æ¸ããããã¿ãããªãã¨ãããã°è¨å®ã®ç®¡çã楽ã«ãªãããã§ãã
*1:mavenã®ãããã¡ã¤ã«ã¨ã
*2:ã«ã»ããã¢ããããã¦ããPlayframework
*3:Playã¢ããªã±ã¼ã·ã§ã³ãPlayã¸ä¾åããªãããã«ããããï¼
*4:2.0.2ã®æç¹ã§ã¯ããããã°ã¢ã¼ãæã¯ä½æ ãconfig.resourceãå¹ãããconfig.fileãå©ç¨ããªãã¨ãã¡ã§ãã
*5:æ£ç¢ºã«ã¯HOCONãªãã¸ã§ã¯ãã®ä¸æ¸ãããã¼ã¸