2015-11-24 148 views
2

我正在使用Eclipse 4.5(Mars)和Play framework 2.4。我使用模板ID play-java创建了一个Java项目。然后我使用命令eclipseactivator控制台创建项目的Eclipse设置。不知怎的,.project文件被修改了,现在Eclipse将Java项目识别为Scala项目。这意味着我没有从Eclipse获得Java帮助。这是.project文件的根项目文件夹中的内容:如何为Play Java项目的Eclipse IDE创建项目设置

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

如果我手动编辑的文件,并与

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

更换线

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

并从activator控制台运行eclipse命令,文件获取覆盖到之前的状态。如何让eclipse将项目识别为Java项目?

回答

2

在你project/plugins.sbt你需要用线:

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

,并在您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 
+0

这是玩2.4的新功能?该项目的默认类型是Scala,而不会将这些行添加到'build.sbt',而早期版本的Play则不是这种情况。 – ajay

+1

设置明确从2.3更改为2.4:https://www.playframework.com/documentation/2.4.x/IDE#Eclipse – Kris