我有一个现有的Play 2.1项目.我一直用控制台运行它,它工作正常.但是,当我尝试使用IntelliJ使用IntelliJ运行它时,它不起作用:
https://www.jetbrains.com/help/idea/getting-started-with-play-2-x.html#run_debug_playApp
首先,我尝试通过右键单击应用程序并选择“运行播放2应用程序”来运行它.它不会运行,它给了我这个错误:
sbt.IncompatiblePluginsException: Binary incompatibility in plugins detected.
在对该问题进行一些研究后,我将-Djline.terminal =添加到我的JVM选项中并再次尝试.这次它运行了,但是当我尝试在浏览器中打开一个页面时出现了这个错误:
Global : Unsupported major.minor version 52.0
最后,我尝试将我的项目重新导入intellij.在它导入之前,它迫使我将build.properties中的SBT版本从0.12.2更新为0.12.4.我这样做了,但仍然遇到上面列出的相同错误.
注意:我将Java 7设置为我的JDK.
这是完整的堆栈跟踪:
play.api.PlayException: Cannot init the Global object[Global : Unsupported major.minor version 52.0] at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:57) ~[play_2.10-2.1.1.jar:2.1.1] at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:51) ~[play_2.10-2.1.1.jar:2.1.1] at play.utils.Threads$.withContextClassLoader(Threads.scala:18) ~[play_2.10-2.1.1.jar:2.1.1] at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:50) ~[play_2.10-2.1.1.jar:2.1.1] at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:383) ~[play_2.10-2.1.1.jar:2.1.1] at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance(Application.scala:383) ~[play_2.10-2.1.1.jar:2.1.1] Caused by: java.lang.UnsupportedClassVersionError: Global : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.7.0_80] at java.lang.ClassLoader.defineClass(ClassLoader.java:800) ~[na:1.7.0_80] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.7.0_80] at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) ~[na:1.7.0_80] at java.net.URLClassLoader.access$100(URLClassLoader.java:71) ~[na:1.7.0_80] at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.7.0_80]
解决方法
问题是由于Java版本不匹配.参考
Wikipedia Java Class Reference:
J2SE 8 = 52
J2SE 7 = 51
导入项目try to change project SDK from Java 8 to Java 7时
javacOptions = Seq(“ – source”,“1.7”,“ – target”,“1.7”)