play-1.2.x 开发环境搭建

建立play项目

play的环境变量配置同java的环境变量配置差不多,将play的主目录添加path环境变量中即可。

使用 play new 命令创建一个新的项目。

$ play new test
set JAVA_OPTS=-Xmx1024m -Xms1024m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:-UseSplitVerifier -Xdebug -Dplay.debug=yes -Dplay.id=test -Dapplication.path="."
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.7, http://www.playframework.org
~
~ The new application will be created in C:\Users\Jie\play\test
~ What is the application name? [test] test(输完回车确认)
~
~ OK, the application is created.
~ Start it with : play run test
~ Have fun!
~

此时,play项目创建完成,但是此时还不能直接导入到编辑器中,还需要创建编辑器所必须的目录和文件才可以,先使用dir命令看看当前项目的目录结构。

导入到编辑器中

eclipse

  1. 先进入到项目的上一级目录,然后使用play eclipsify 项目名称创建eclipse编辑器所需的文件。
$ cd test
$ play eclipsify test
set JAVA_OPTS=-Xmx1024m -Xms1024m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:-UseSplitVerifier -Xdebug -Dplay.debug=yes -Dplay.id=test -Dapplication.path="."
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.7, http://www.playframework.org
~
~ OK, the application "test" is ready for eclipse
~ Use File/Import/General/Existing project to import C:\Users\Jie\play\test into eclipse
~
~ Use eclipsify again when you want to update eclipse configuration files.
~ However, it's often better to delete and re-import the project into your workspace since eclipse keeps dirty caches...
~

2.进入到项目的根目录,使用dir命令查看下项目的目录结构,此时多出了目录.classpath.project文件和、.settingseclipse目录,接下来要做的只需要通过eclipseimport功能导入项目即可。

2016/06/18  15:46             6,330 .classpath
2016/06/18  15:46               443 .project
2015/04/21  19:49    <DIR>          .settings
2016/06/18  15:38    <DIR>          app
2016/06/18  15:38    <DIR>          conf
2016/06/18  15:46    <DIR>          eclipse
2016/06/18  15:38    <DIR>          lib
2016/06/18  15:38    <DIR>          public
2016/06/18  15:38    <DIR>          test

idea

1.cd ../project,使用play idealize 项目名称创建idea编辑器所需要的目录和文件。

此步骤可省略,通过idea导入Module的时候选择新建即可,或者选择eclipse项目

$ play idealize test
set JAVA_OPTS=-Xmx1024m -Xms1024m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:-UseSplitVerifier -Xdebug -Dplay.debug=yes -Dplay.id=test -Dapplication.path="."
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.7, http://www.playframework.org
~
~ OK, the application is ready for Intellij Idea
~ Use File, Open Project... to open "test.ipr"

2.cd project,使用dir命令看看项目的目录结构,发现多出了test.imltest.ipr文件,这两个文件是idea编辑器所需要的文件,接着将项目导入idea中即可。

2016/06/18  16:00    <DIR>          app
2016/06/18  16:00    <DIR>          conf
2016/06/18  16:00    <DIR>          lib
2016/06/18  16:00    <DIR>          public
2016/06/18  16:00    <DIR>          test
2016/06/18  16:00             1,952 test.iml
2016/06/18  16:00               479 test.ipr

3.运行环境配置
1.选择工具栏上的Edit Configurations

2.配置默认application > Configuration

// Main class 配置此项应当提前将jar加入Module中,否则将会提示错误,可先保存后续加入play-1.2.x.jar
play.server.Server
// VM options
-Xmx1024m -Xms1024m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:-UseSplitVerifier -Xdebug -Dplay.debug=yes -Dplay.id=test -Dapplication.path="."
//Working directory 填写项目根目录
//JRE 选择jdk版本

3.点击左上角+新建applicaton,仅需修改Working directory(多模块为主Module根目录)、 Use classpath of module(主Module)项即可

4.打开Project Structure项目配置弹框,选择左侧Modules项,右侧选择主Module > sources,将public、conf目录设置为Resources,不需要在idea中搜索到或显示的目录设为Excluded即可,其他模块也应该一一设置。

5.点击工具栏中的Debug绿色图标启动项目即可

https://www.fank243.com/posts/725fe360.html

转载于:https://my.oschina.net/skyAcross/blog/700610

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值