【问题标题】:How do I get IntelliJ to display the Scala compilation deprecation warnings如何让 IntelliJ 显示 Scala 编译弃用警告
【发布时间】:2018-12-09 17:34:00
【问题描述】:

在 IntelliJ(版本:2016.3.1,Scala 插件版本:2016.3.5)中,我有一个 Scala 2.12(这意味着需要 Java 1.8)项目,我在其中选择“构建/重建项目”。我在“消息”窗口中收到以下输出:

Warning:scalac: there were four deprecation warnings (since 2.12.0); re-run with -deprecation for details

我必须采取哪些步骤来配置我的项目才能真正看到 4 个警告的内容?

我发现another question for IntelliJ 14 显示了如何打开弃用警告,但没有说明如何显示弃用警告本身的实际内容。任何有关这方面的指导将不胜感激。

【问题讨论】:

    标签: scala intellij-idea deprecation-warning


    【解决方案1】:

    将以下内容添加到您的 sbt 构建文件中:

    scalacOptions += "-deprecation"
    

    【讨论】:

    • 完美!我已经为此烦恼了一年多。在进行 2.12 升级时,我终于有时间在这里写下这个问题。我很高兴我做到了!
    • 太棒了!更多 scalac 选项可能对您有所帮助:blog.threatstack.com/…
    • 这个答案假设读者正在使用特定的构建工具。但是,问题没有提到“sbt”,也没有“sbt”标签。因此,对于这个问题,这个答案是题外话
    【解决方案2】:

    目前最新的Intellij版本,还可以打开Settings->Build, Execution, Deployment->Compiler->Scala Compiler,在Additional compiler options:中追加-deprecation

    【讨论】:

    • IntelliJ 2022.1 和 Scala Plugin 2022.1.13 (2022/Apr/26) 的路径,在 Options 部分遵循 Settings -> Build, Execution, Deployment -> Compiler -> Scala_Compiler(在右侧的“功能”部分)点击复选框“弃用警告”。
    猜你喜欢
    • 2011-06-12
    • 2023-01-29
    • 1970-01-01
    • 2010-09-11
    • 2019-02-20
    • 2023-03-17
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多