IntelliJ and Play framework

2020-06-18 19:52发布

问题:

IntelliJ claims to work with the Play framework. I can't get it to work.

  1. Install IDEA 14.0
  2. Install Scala plugin 1.1.1
  3. Open project directory in IntelliJ
  4. Import as SBT

After importing, I don't see my source files.


My barebones Play project:

build.sbt

name := "foo"

version := "1.0-SNAPSHOT"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache
)

lazy val root = (project in file(".")).enablePlugins(PlayScala)

project/plugins.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.4")

conf/routes

GET / controllers.Application.index()

app/controllers/Application.scala

package controllers
import play.api.mvc._
object Application extends Controller {
  def index = Action {
    Ok("It works!")
  }
}

This process works fine for a basic SBT project, but not for Play projects.


EDIT: These are my logs from that session:

2014-11-19 13:45:58,421 [      0]   INFO -        #com.intellij.idea.Main - ------------------------------------------------------ IDE STARTED ------------------------------------------------------ 
2014-11-19 13:45:58,446 [     25]   INFO -        #com.intellij.idea.Main - IDE: IntelliJ IDEA (build #IC-139.225.3, 11 Nov 2014 00:00) 
2014-11-19 13:45:58,447 [     26]   INFO -        #com.intellij.idea.Main - OS: Linux (3.11.0-26-generic, amd64) 
2014-11-19 13:45:58,447 [     26]   INFO -        #com.intellij.idea.Main - JRE: 1.8.0_25-b17 (Oracle Corporation) 
2014-11-19 13:45:58,447 [     26]   INFO -        #com.intellij.idea.Main - JVM: 25.25-b02 (Java HotSpot(TM) 64-Bit Server VM) 
2014-11-19 13:45:58,449 [     28]   INFO -        #com.intellij.idea.Main - JVM Args: -Xms128m -Xmx750m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=225m -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -Djsse.enableSNIExtension=false -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -Dawt.useSystemAAFontSettings=lcd -Djb.vmOptionsFile=/opt/idea/bin/idea64.vmoptions -XX:ErrorFile=/home/paul/java_error_in_IDEA_%p.log -Xbootclasspath/a:/opt/idea/bin/../lib/boot.jar -Didea.paths.selector=IdeaIC14 -Djb.restart.code=88 
2014-11-19 13:45:58,504 [     83]   INFO -        #com.intellij.idea.Main - JNA library loaded (64-bit) in 54 ms 
2014-11-19 13:45:58,647 [    226]   INFO - .intellij.idea.IdeaApplication - WM detected: Mutter 
2014-11-19 13:45:58,648 [    227]   INFO - llij.openapi.wm.impl.X11UiUtil - impersonated WM: MUTTER_WM 
2014-11-19 13:45:59,645 [   1224]   INFO - llij.ide.plugins.PluginManager - 31 plugins initialized in 747 ms 
2014-11-19 13:45:59,647 [   1226]   INFO - llij.ide.plugins.PluginManager - Loaded bundled plugins: Android Support (10.0.8.12), Ant Support (1.0), Bytecode Viewer (0.1), CVS Integration (11), Commander (1.0.0), Copyright (8.1), Coverage, Eclipse Integration (3.0), EditorConfig (1.0), Git Integration (8.1), GitHub, Gradle, Groovy (9.0), I18n for Java, IDEA CORE, IntelliLang (8.0), JUnit (1.0), Java Bytecode Decompiler (0.1), JavaFX (1.0), Maven Integration, Plugin DevKit (1.0), Properties Support, Subversion Integration (1.1), Task Management (1.0), Terminal (0.1), TestNG-J (8.0), UI Designer, XPathView + XSLT Support (4), XSLT-Debugger (1.4), hg4idea (10.0) 
2014-11-19 13:45:59,647 [   1226]   INFO - llij.ide.plugins.PluginManager - Loaded custom plugins: Scala (1.1.1) 
2014-11-19 13:46:00,710 [   2289]   INFO - ellij.util.io.PagedFileStorage - lower=100; upper=200; buffer=10; max=739246080 
2014-11-19 13:46:00,961 [   2540]   INFO - api.vfs.impl.local.FileWatcher - Starting file watcher: /opt/idea/bin/fsnotifier64 
2014-11-19 13:46:00,972 [   2551]   INFO - api.vfs.impl.local.FileWatcher - Native file watcher is operational. 
2014-11-19 13:46:01,674 [   3253]   INFO - lij.diagnostic.DebugLogManager - Set DEBUG for the following categories: [] 
2014-11-19 13:46:02,914 [   4493]   INFO -                  TestNG Runner - Create TestNG Template Configuration 
2014-11-19 13:46:02,941 [   4520]   INFO -                  TestNG Runner - Create TestNG Template Configuration 
2014-11-19 13:46:03,055 [   4634]   INFO - ellij.project.impl.ProjectImpl - 22 project components initialized in 554 ms 
2014-11-19 13:46:03,056 [   4635]   INFO - le.impl.ModuleManagerComponent - 0 module(s) loaded in 0 ms 
2014-11-19 13:46:03,494 [   5073]   INFO - pl.stores.ApplicationStoreImpl - 88 application components initialized in 3703 ms 
2014-11-19 13:46:03,497 [   5076]   INFO - .intellij.idea.IdeaApplication - App initialization took 5904 ms 
2014-11-19 13:46:10,046 [  11625]   WARN - ewvfs.persistent.RefreshWorker - [+] fs=LocalFileSystem dir=file:/// name=C:\nppdf32Log\debuglog.txt 
2014-11-19 13:46:10,172 [  11751]   WARN - ewvfs.persistent.RefreshWorker - [+] fs=LocalFileSystem dir=file:///home/paul name=C:\nppdf32Log\debuglog.txt 
2014-11-19 13:46:18,667 [  20246]   INFO - ution.rmi.RemoteProcessSupport - /usr/lib/jvm/java-8-oracle/jre/bin/java -Djava.awt.headless=true -Dsun.rmi.transport.connectionTimeout=3600000 -Dexternal.system.id=SBT -Dfile.encoding=UTF-8 -classpath /opt/idea/lib/idea.jar:/opt/idea/lib/resources_en.jar:/opt/idea/lib/jna-utils.jar:/opt/idea/lib/util.jar:/opt/idea/lib/oromatcher.jar:/opt/idea/lib/annotations.jar:/opt/idea/lib/trove4j.jar:/opt/idea/lib/picocontainer.jar:/opt/idea/lib/jna.jar:/opt/idea/lib/jdom.jar:/opt/idea/lib/log4j.jar:/opt/idea/lib/openapi.jar:/opt/idea/lib/extensions.jar:/home/paul/.IdeaIC14/config/plugins/Scala/lib/scala-plugin.jar:/home/paul/.IdeaIC14/config/plugins/Scala/lib/scala-library.jar:/home/paul/.IdeaIC14/config/plugins/Scala/lib/scala-xml_2.11-1.0.2.jar com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacadeImpl org.jetbrains.sbt.project.SbtProjectResolver org.jetbrains.sbt.project.SbtTaskManager 
2014-11-19 13:46:18,876 [  20455]   INFO - ution.rmi.RemoteProcessSupport - Port/ID: 13092/RemoteExternalSystemFacadeImpl6406aaf3 
2014-11-19 13:46:32,486 [  34065]   INFO -                  TestNG Runner - Create TestNG Template Configuration 
2014-11-19 13:46:33,002 [  34581]   INFO - ellij.project.impl.ProjectImpl - 163 project components initialized in 842 ms 
2014-11-19 13:46:33,002 [  34581]   INFO - le.impl.ModuleManagerComponent - 0 module(s) loaded in 0 ms 
2014-11-19 13:46:33,008 [  34587]   INFO - i.vcs.changes.ChangeListWorker - default list not found when copy 
2014-11-19 13:46:33,008 [  34587]   INFO - i.vcs.changes.ChangeListWorker - default list not found when copy in original object too 
2014-11-19 13:46:34,208 [  35787]   INFO - rains.ide.BuiltInServerManager - built-in server started, port 63342 
2014-11-19 13:46:34,266 [  35845]   WARN - openapi.wm.impl.ToolWindowImpl - ToolWindow icons should be 13x13. Please fix ToolWindow (ID:  SBT) or icon jar:file:/home/paul/.IdeaIC14/config/plugins/Scala/lib/scala-plugin.jar!/sbt.png 
2014-11-19 13:46:34,367 [  35946]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 295 ms 
2014-11-19 13:46:34,392 [  35971]   WARN - ewvfs.persistent.RefreshWorker - [+] fs=LocalFileSystem dir=file:/// name=C:\nppdf32Log\debuglog.txt 
2014-11-19 13:46:34,404 [  35983]   WARN - ewvfs.persistent.RefreshWorker - [+] fs=LocalFileSystem dir=file:///home/paul name=C:\nppdf32Log\debuglog.txt 
2014-11-19 13:46:35,380 [  36959]  ERROR - tartup.impl.StartupManagerImpl - Can't deserialize target data of key 'Play2ProjectData'. Given class loaders: [com.intellij.util.lang.UrlClassLoader@7ef20235, com.intellij.util.lang.UrlClassLoader@7ef20235] 
java.lang.IllegalStateException: Can't deserialize target data of key 'Play2ProjectData'. Given class loaders: [com.intellij.util.lang.UrlClassLoader@7ef20235, com.intellij.util.lang.UrlClassLoader@7ef20235]
    at com.intellij.openapi.externalSystem.model.DataNode.prepareData(DataNode.java:182)
    at com.intellij.openapi.externalSystem.model.DataNode.getData(DataNode.java:91)
    at com.intellij.openapi.externalSystem.model.DataNode.toString(DataNode.java:273)
    at java.lang.String.valueOf(String.java:2981)
    at java.lang.StringBuilder.append(StringBuilder.java:131)
    at java.util.AbstractCollection.toString(AbstractCollection.java:462)
    at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2886)
    at java.util.Formatter$FormatSpecifier.print(Formatter.java:2763)
    at java.util.Formatter.format(Formatter.java:2520)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2927)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:109)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:98)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:124)
    at com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportBuilder$1$1$1.run(AbstractExternalProjectImportBuilder.java:143)
    at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:325)
    at com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportBuilder$1$1.execute(AbstractExternalProjectImportBuilder.java:140)
    at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$6$1.run(ExternalSystemApiUtil.java:374)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:974)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$6.run(ExternalSystemApiUtil.java:371)
    at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2102)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:391)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:369)
    at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:365)
    at com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportBuilder$1.run(AbstractExternalProjectImportBuilder.java:137)
    at com.intellij.ide.startup.impl.StartupManagerImpl$8.run(StartupManagerImpl.java:329)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runActivity(StartupManagerImpl.java:303)
    at com.intellij.ide.startup.impl.StartupManagerImpl.access$700(StartupManagerImpl.java:51)
    at com.intellij.ide.startup.impl.StartupManagerImpl$3.run(StartupManagerImpl.java:164)
    at com.intellij.openapi.project.DumbServiceImpl.runWhenSmart(DumbServiceImpl.java:125)
    at com.intellij.ide.startup.impl.StartupManagerImpl.queueSmartModeActivity(StartupManagerImpl.java:161)
    at com.intellij.ide.startup.impl.StartupManagerImpl.access$1000(StartupManagerImpl.java:51)
    at com.intellij.ide.startup.impl.StartupManagerImpl$4.run(StartupManagerImpl.java:184)
    at com.intellij.openapi.project.DumbServiceImpl.updateFinished(DumbServiceImpl.java:246)
    at com.intellij.openapi.project.DumbServiceImpl.access$700(DumbServiceImpl.java:51)
    at com.intellij.openapi.project.DumbServiceImpl$9.run(DumbServiceImpl.java:405)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
    at java.awt.EventQueue.access$400(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.awt.EventQueue$3.run(EventQueue.java:691)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:748)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:577)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.sbt.project.data.Play2ProjectData
    at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:148)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:344)
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
    at com.intellij.openapi.externalSystem.model.DataNode$1.resolveClass(DataNode.java:127)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
    at com.intellij.openapi.externalSystem.model.DataNode.prepareData(DataNode.java:172)
    ... 53 more
2014-11-19 13:46:35,384 [  36963]  ERROR - tartup.impl.StartupManagerImpl - IntelliJ IDEA 14.0.1  Build #IC-139.225.3 
2014-11-19 13:46:35,384 [  36963]  ERROR - tartup.impl.StartupManagerImpl - JDK: 1.8.0_25 
2014-11-19 13:46:35,384 [  36963]  ERROR - tartup.impl.StartupManagerImpl - VM: Java HotSpot(TM) 64-Bit Server VM 
2014-11-19 13:46:35,384 [  36963]  ERROR - tartup.impl.StartupManagerImpl - Vendor: Oracle Corporation 
2014-11-19 13:46:35,385 [  36964]  ERROR - tartup.impl.StartupManagerImpl - OS: Linux 
2014-11-19 13:46:35,385 [  36964]  ERROR - tartup.impl.StartupManagerImpl - Last Action:  
2014-11-19 13:46:35,959 [  37538]   INFO - CompilerWorkspaceConfiguration - Available processors: 8 
2014-11-19 13:46:36,275 [  37854]   INFO - tor.impl.FileEditorManagerImpl - Project opening took 4147 ms 

回答1:

This is a bug filed here and tracked here.

The solution is to use the nightly build: https://confluence.jetbrains.com/display/SCA/Scala+Plugin+Nightly+Builds+for+Cassiopeia

You can

  • manually download it and add it to IDEA's plugins directory

  • or from within IDEA, add the http://www.jetbrains.com/idea/plugins/scala-nightly-cassiopeia.xml repository and install scala-intellij-bin.