您的位置:首页 > 编程语言 > Java开发

play-1.2.x 开发环境搭建

2016-06-24 20:34 441 查看
摘要: Eclipse、idea开发环境搭建

建立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

先进入到项目的上一级目录,然后使用
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
文件和、
.settings
eclipse
目录,接下来要做的只需要通过
eclipse
import
功能导入项目即可。

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
3ff0
"

2.
cd project
,使用
dir
命令看看项目的目录结构,发现多出了
test.iml
test.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
绿色图标启动项目即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java play-1.2.x