gpt4 book ai didi

intellij-idea - Play2 和 Intellij 未检测到主类

转载 作者:行者123 更新时间:2023-12-04 05:52:24 44 4
gpt4 key购买 nike

我正在尝试在 sbt 子项目中开发一个 Play Framework 应用程序。目录树如下所示:

- main-project
|--sub-project
| |--app
| |--conf
| |--logs
| |--public
| |--test
|--project
|--build.sbt

如果我尝试使用 sbt shell 和以下命令运行 Play 应用程序
sub-project/run
Play 正确开始。
但是,如果我尝试使用 IntelliJ 运行配置运行它,则会收到错误 java.lang.RuntimeException: No main class detected.
遵循日志的第一行和 IJ 启动的命令:
/usr/java/jdk1.8.0_111/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:41258,suspend=y,server=n -Dfile.encoding=UTF8 -Djline.terminal=none -Dsbt.log.noformat=true -Dsbt.global.base=/tmp/sbt-global-pluginstub -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -javaagent:/home/myusername/Programmi/idea-IU-173.3727.127/lib/rt/debugger-agent.jar=/tmp/capture.props -classpath /home/myusername/.IntelliJIdea2017.3/config/plugins/Scala/launcher/sbt-launch.jar:/home/myusername/Programmi/idea-IU-173.3727.127/lib/idea_rt.jar xsbt.boot.Boot "project sub-project" run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
Connected to the target VM, address: '127.0.0.1:41258', transport: 'socket'
[warn] No sbt.version set in project/build.properties, base directory: /home/luca/IdeaProjects/main-project/sub-project
[info] Set current project to sub-project (in build file:/home/myusername/IdeaProjects/main-project/sub-project/)
[info] Updating {file:/home/myusername/IdeaProjects/main-project/sub-project/}sub-project...
[info] Done updating.
[error] java.lang.RuntimeException: No main class detected.

看起来 sbt 命令与预期不同( sbt project sub-project run insted of sbt sub-project/run )

有人曾经配置 IntelliJ 来使用启动工具调试 Play 应用程序吗?
谢谢

最佳答案

@Luca:这是因为 scala 插件 sbt 版本、激活器和 Intellij idea 之间的插件版本冲突。新的 Intellij 试图忽略 $PROJECT_DIR 文件,其他 flougins 将 conf 文件放在那里。

解决方法:
把它放在你的 play2_project_settings.xml 中:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Play2ExcludedModulesSettings">
<option name="INFO">
<map>
<entry key="api">
<value>
<ProjectSettingsEntry>
<option name="confDir" value="$PROJECT_DIR$/api/app" />
<option name="templateImports">
<list>
<option value="_root_.play.twirl.api.TwirlFeatureImports._" />
<option value="_root_.play.twirl.api.TwirlHelperImports._" />
<option value="_root_.play.twirl.api.Html" />
<option value="_root_.play.twirl.api.JavaScript" />
<option value="_root_.play.twirl.api.Txt" />
<option value="_root_.play.twirl.api.Xml" />
<option value="models._" />
<option value="controllers._" />
<option value="play.api.i18n._" />
<option value="views.xml._" />
<option value="play.api.templates.PlayMagic._" />
<option value="play.api.mvc._" />
<option value="play.api.data._" />
</list>
</option>
<option name="routesImports">
<list>
<option value="controllers.Assets.Asset" />
</list>
</option>
<option name="uri" value="$PROJECT_DIR$/../../../../<custom-project-path>" />
</ProjectSettingsEntry>
</value>
</entry>
<entry key="chargeback-api">
<value>
<ProjectSettingsEntry>
<option name="playDistrPath" value="$USER_HOME$/.coursier/cache/v1/https/repo1.maven.org/maven2/com/typesafe/play/play_2.12/2.6.11/play_2.12-2.6.11.jar" />
</ProjectSettingsEntry>
</value>
</entry>
</map>
</option>
</component>
</project>

Filepath

在 custom-project-path 中放置项目目录的绝对路径,它会像魅力一样工作!!

关于intellij-idea - Play2 和 Intellij 未检测到主类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49455856/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com