Play Framework 2.6 (Java) environment construction in Eclipse

This is a summary of the procedure for creating a new Play Framework 2.6 (Java) project and importing it into Eclipse. Since the activator command that was used up to v2.5.x has reached EOL, sbt [^ 1] will be used directly after v2.6.x.

Pre-conditions

Install sbt with Homebrew for Mac and from here for Windows. Please give me. If sbt is already included, you can check the version with the about option.

$ sbt about
=> [info] This is sbt 1.0.4

Project creation

sbt new [Template name]Create a new project with. You will be asked for the project name and scala version, but if you press enter without entering anything[]The default value in is adopted.

$ sbt new playframework/play-java-seed.g8
[info] Set current project to play (in build file:〜〜〜)

This template generates a Play Java project

name [play-java-seed]:
organization [com.example]:
scala_version [2.12.3]:
play_version [2.6.7]:
sbt_version [1.0.2]:

The app is launched by sbt run, http://localhost:You can check the operation from 9000 (in the case of the first execution, it takes time because the library is dropped).



### Add settings for Eclipse
 Added plugin settings to project / plugins.sbt.


#### **`plugins.sbt`**
```sbt

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

Next, add the settings for Eclipse to build.sbt.

build.sbt


EclipseKeys.preTasks := Seq(compile in Compile, compile in Test)
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)

Import into eclipse

Generate .classpath and .project files for Eclipse.

$ sbt eclipse

You can now import it into Eclipse (File> Import> Existing Projects into Workspace). However, in the imported state in this way, Eclipse does not refer to the class generated from view (* .scala.html), so a compile error occurs in Controller. To solve this, set an additional build path.

  1. Right-click on the project in Eclipse> Build Path> Configure Build Path ...
  2. Select Add Class Folder from the Library tab
  3. In the dialog that opens, check target / scala-2.12 / classes and OK

スクリーンショット 2017-12-02 13.47.20.png

[^ 1]: Build tool for Scala. activator used sbt internally

Recommended Posts

Play Framework 2.6 (Java) environment construction in Eclipse
JavaFX environment construction in Java 13
Play Framework 2.6 (Java) development environment creation
[Java] Environment construction
Java environment construction
Play Framework2.5 (Java) Tips
[Environment construction] Eclipse installation
java development environment construction
[Note] Struts2 environment construction using Gradle in Eclipse
[LeJOS] Let's program mindstorm-EV3 in Java [Environment construction part 2]
Null-safe program in Java (Eclipse)
Java development environment (Mac, Eclipse)
[Java] Environment construction procedure for developing struts 1.3 with Eclipse
AtCoder Challenge Environment Construction (Java 8)
First Java development in Eclipse
Validation function in Play Framework
Java development environment construction (Mac + Pleiades All in One Eclipse 4.7 + Spring Boot + Gradle (Buildship))
[LeJOS] Let's program mindstorm-EV3 in Java [Environment construction first part]
[Eclipse Java] Development environment setting memo
Java Spring environment in vs Code
Try running Selenuim 3.141.59 in eclipse (java)
Hello World in java in eclipse now
About Eclipse environment (Java, Liberty, JavaScript)
[Java & SpringBoot] Environment Construction for Mac
Play with Markdown in Java flexmark-java
JPA (Java Persistence API) in Eclipse
java framework
[ev3 × Java] leJOS development environment construction (Eclipse on Mac OSX / bluetooth)
A story stuck with log output in Docker + Play framework environment
Java container performance degradation in Menicoa environment
Java runtime environment construction method (Tomcat @ Linux)
[Processing x Java] Construction of development environment
Building a Lambda development environment in Eclipse
Java development environment construction memo on Mac
[Java] Set AdoptOpen JDK in STS (Eclipse)
Spring Boot + Docker Java development environment construction
Play RAW, WAV, MP3 files in Java
Post to Slack from Play Framework 2.8 (Java)
Java application development environment created in VM environment
Minimal Java environment construction and Hello World
JSP + Eclipse + Jetty development environment construction that even Java beginners can do
Technology for reading Java source code in Eclipse
Partization in Java
Create a simple batch processing framework in Eclipse.
When there are environment variables in Java tests
Changes in Java 11
Solution for NetBeans 8.2 not working in Java 9 environment
JAVA + STS (Spring Tool Suite) environment construction procedure
Rock-paper-scissors in Java
MVC in Eclipse.
[Notepad ++] C language / Java compilation & execution environment construction
Play Framework study
Java framework comparison
Allow development in Eclipse environment using iPLAss SDK
[Spring] Environment construction
Pi in Java
Points stuck in building VSCode & Java development environment
Docker environment construction
[Beginner] Install java development tool in cloud9 development environment.
FizzBuzz in Java
Handle JSON in cross domain with Play Framework