简体   繁体   English

如何为 Play Java 项目的 Eclipse IDE 创建项目设置

[英]How to create project setting for Eclipse IDE of a Play Java project

I am using Eclipse 4.5 (Mars) and Play framework 2.4.我正在使用 Eclipse 4.5 (Mars) 和 Play 框架 2.4。 I created a Java project using the template id play-java .我使用模板 id play-java创建了一个 Java 项目。 Then I created Eclipse settings for the project using the command eclipse at activator console.然后我在activator控制台使用命令eclipse为项目创建了 Eclipse 设置。 Somehow, the .project file got changed and now Eclipse recognizes Java project as Scala project.不知何故, .project文件发生了变化,现在 Eclipse 将 Java 项目识别为 Scala 项目。 This means I get no Java help from Eclipse.这意味着我无法从 Eclipse 获得 Java 帮助。 This is the content of the .project file in the root project folder:这是根项目文件夹中.project文件的内容:

<projectDescription>
  <name>YMLPushNotificationService</name>
  <buildSpec>
    <buildCommand>
      <name>org.scala-ide.sdt.core.scalabuilder</name>
    </buildCommand>
  </buildSpec>
  <natures>
    <nature>org.scala-ide.sdt.core.scalanature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
  </natures>
  <linkedResources> </linkedResources>
</projectDescription>

If I manually edit the file and replace the line如果我手动编辑文件并替换该行

<name>org.scala-ide.sdt.core.scalabuilder</name>

with

<name>org.eclipse.jdt.core.javabuilder</name>

and run the eclipse command from activator console, the file gets overwritten to its previous state.并从activator控制台运行eclipse命令,该文件将被覆盖为其以前的状态。 How do I make eclipse recognize the project as Java project?如何让 Eclipse 将项目识别为 Java 项目?

In your project/plugins.sbt you need a line with:在您的project/plugins.sbt您需要一行:

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

and in your build.sbt the following lines:并在您的build.sbt中添加以下几行:

import com.typesafe.sbteclipse.core.EclipsePlugin.EclipseKeys

EclipseKeys.projectFlavor := EclipseProjectFlavor.Java           // Java project. Don't expect Scala IDE
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)  // Use .class files instead of generated .scala files for views and routes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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