简体   繁体   中英

How to make a play framework based project into a eclipse project in a better form?

I am using play framework 1.2.4,and also trying 2.2.1.

In 1.2.4,I created a new play framework based project by using

play new wonder

then I entered its directory,and ran this command

play eclipsify

It was done successfully.And I imported it to eclipse,it worked,but was not pretty good,you will see why

(I am new here,and I don't have 10 reputation to post images,so I post images to another website,link is follow)

http://imgur.com/P3J6zSy

(Here is another screenshot that shows the result of what I have done in Ubuntu 12.04 with play-2.2.1 http://imgur.com/zkDTtvY )

The related jars were just listed in the root directory,and it was so long.

First,how can I make it not list in that way?

Second,as what you see,these jars were linked to this project rather than copied to the sub-directory of this project.

If I want to make them copied to the sub-directory of this project when generating eclipse project,what should I do?

ps: When I trying 2.2.1,there are not much different.If you know how to do in any one of these 2 versions,just tell me,thanks a lot!

Instructions for importing a new Play Java project into Eclipse, tested with Play Framework 2.2.1 and Eclipse Standard 4.3.1:

  1. Download and install Eclipse .

  2. Create a new Play project. When asked, select the Java language:

     $ play new myapp 
  3. Change to the new application's directory:

     $ cd myapp 
  4. Generate the Eclipse project:

    • Without including library source code:

       $ play eclipse 
    • Including library source code (may take a long time for downloads and a few sources might be missing):

       $ play "eclipse with-source=true" 
  5. Import the project into your Eclipse Workspace with File | Import | General | Existing Projects into Workspace File | Import | General | Existing Projects into Workspace File | Import | General | Existing Projects into Workspace .

Result:

播放导入到Eclipse中的项目

For more information see Setting up your preferred IDE .

我不确定您是否会得到这个问题的答案,对于所有将面临类似问题的人们,在按照官方文档中的所有步骤进行操作之后,我仍然面临有问题的相同问题,解决方案是您需要打开Scala eclipse中的透视图默认为J2EE

Well, the post is answered already but these commands are not supported in new versions of play. For users who are using new versions of play, here is the step by step guide for creation and import of play project in eclipse:

**Prerequisites:** java 1.8

type in terminal

java -version

to check if java is installed. you should see something like:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

If it is not present then you can download from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html To Create a new application using SBT you must have sbt 0.13.13 or higher installed (download from here https://www.scala-sbt.org/ ) open terminal and type following command to generate java project.

 sbt new playframework/play-java-seed.g8 

if you are on windows platform use sbt.bat instead of sbt

 sbt.bat new playframework/play-java-seed.g8 

在此处输入图片说明

在此处输入图片说明

use following command for a scala project:

 sbt new playframework/play-scala-seed.g8
 sbt.bat  new playframework/play-scala-seed.g8

After that, use

sbt run

and then go to http://localhost:9000 to see the running server. Now, you have successfully created your scala or java project. Next step is importing it to an IDE. Lets' import it to eclipse. If your project contain mixed code java + scala then you have to download scala ide plugin to you eclipse. open eclipse -> Help ->Install new software -> click Add -> Add repository Name: scala ide Location : http://download.scala-ide.org/sdk/lithium/e47/scala212/stable/site click Add.

在此处输入图片说明

After successfully adding the scala ide add following dependency in your project/plugins.sbt file.

 addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.2")

You must compile your project before running the eclipse command. You can force compilation to happen when the eclipse command is run by adding the following setting in build.sbt:

// Compile the project before generating Eclipse files, so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile, compile in Test)

After compilation of project go to your project folder and type

 $sbt eclipse

The plug-in generates the two files Eclipse needs, the .classpath and .project files.

Once these files are generated, go to Eclipse and follow the usual steps to import a project into the Eclipse workspace: File → Import → Existing Projects into Workspace. Your project will then appear in the Eclipse Navigator, Project Explorer, Package Explorer, and other views.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM