3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Play Framework 2.6 (Java) の開発環境作成

Last updated at Posted at 2017-10-14

PlayFramework2 徹底入門」でModelを作成するところでimport分が全く効かなかったのでメモ

環境
  • windows 10
  • eclipse oxygen
プロジェクトを作成(ディレクトリは任意)
c:¥hoge>activator new [作成したプロジェクトの名前] play-java
ディレクトリの移動
c:¥hoge>cd [作成したプロジェクト]
plugins.sbtに追記
plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.6")
# 追加
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
#addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.2")
eclipse用に変換
c:¥hoge¥hoge>activator eclipse
アプリケーション起動
c:¥hoge¥hoge>activator run

ここまでは順調だったが、model作成時にハマってしまった。

問題のjavaファイル

Message.java
package models;

import java.util.Date;
import javax.persistence.*;
import com.avaje.ebean.Model;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
public class Message extends Model {
    @Id
    public Long id;
    public String name;
    public String mail;
    public String message;
    public Date pastDate;
}

plugins.sbtに追記

plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.6")
# 追加
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
# コメント解除
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.2")
build.sbtに追記
build.sbt
lazy val root = (project in file(".")).enablePlugins(PlayJava)
                .enablePlugins(PlayEbean) // 追記
scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  javaJpa, // 追記
  "org.postgresql" % "postgresql" % "9.4.1212.jre7", // 追記
  "org.projectlombok" % "lombok" % "1.16.10" // 追記
)
activatorアップデート
c:¥hoge¥hoge>activator update
eclipseに反映
c:¥hoge¥hoge>activator "eclipse with-source=true"
コンパイル
c:¥hoge¥hoge>activator compile

一先ず解決。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?