play framework 從環境搭建到簡單執行
阿新 • • 發佈:2018-12-26
download
官網:https://www.playframework.com/
將zip下載至本地,進行unzip。
環境變數
檢測是否安裝成功:解壓成功後進入解壓的目錄,執行
play
終端顯示
zsh: command not found: play
需要配置環境變數
mac /linux:
zsh:
vi ~/.zshrc
新增如下配置
export PLAY_HOME=/Users/leesin/Downloads/play-1.4.3
export PATH=$PATH:$PLAY_HOME
bash:
vi ~/.bash_profile
新增如下配置
export PLAY_HOME=/Users/leesin/Downloads/play-1.4.3
export PATH=$PATH:$PLAY_HOME
windows略
然後執行
➜ play-1.4.3 play
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.4.3, https://www.playframework.com
~
~ Usage: play cmd [app_path] [--options]
~
~ with, new Create a new application
~ run Run the application in the current shell
~ help Show play help
說明成功了。
啟動
建立一個專案,這個專案的地址在 play-1.4.3目錄下
➜ play-1.4.3 play new leesin
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.4.3, https://www.playframework.com
~
~ The new application will be created in /Users/leesin/Downloads/play-1.4.3/leesin
~ What is the application name? [leesin] leesin
~
~ OK, the application is created.
~ Start it with : play run leesin
~ Have fun!
~
執行專案:
➜ play-1.4.3 play run leesin
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.4.3, https://www.playframework.com
~
~ Ctrl+C to stop
~
~ using java version "1.7.0_60"
objc[57175]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java (0x10bebb4c0) and /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10bf684e0). One of the two will be used. Which one is undefined.
Listening for transport dt_socket at address: 8000
11:06:15,185 INFO ~ Starting /Users/leesin/Downloads/play-1.4.3/leesin
瀏覽器訪問:
loaclahost:9000
轉化成能匯入eclipse idea的專案
執行
play eclipse
然後匯入即可
play-1.4.3錯誤
java.lang.RuntimeException: Need to restart Play because /Users/leesin/Downloads/play-1.4.3/leesin/conf/application.conf has been changed
at play.ConfigurationChangeWatcherPlugin.onConfigurationFileChanged(ConfigurationChangeWatcherPlugin.java:30)
at play.ConfigurationChangeWatcherPlugin.detectChange(ConfigurationChangeWatcherPlugin.java:24)
at play.plugins.PluginCollection.detectChange(PluginCollection.java:598)
at play.Play.detectChanges(Play.java:641)
at play.Invoker$Invocation.init(Invoker.java:199)
at Invocation.HTTP Request(Play!)
11:06:36,412 INFO ~ Application 'leesin' is now started !
這個問題已經在1.4.4中得到了修復。
但是經過本人測試,還是會有相同的錯誤,不過不影響業務,目前先擱置。