2017-03-02 135 views

回答

1

首先,请按照the documentation中的说明操作。

要在IntelliJ IDEA中配置注释处理,请使用对话框首选项>项目设置>编译器>注释处理器。

接下来,问题是sbt将我们生成的源文件放在target/scala-2.n/classes/our/package。这是编译的.class文件的目录,所以我们需要我们的资源在别处生成。编辑理念的设置不会帮助我们在这里,所以我们需要通过添加编辑build.sbt如下:

// tell sbt (and by extension IDEA) that there is source code in target/generated_sources 
managedSourceDirectories in Compile += baseDirectory.value/"target"/"generated_sources" 
// before compilation happens, create the target/generated_sources directory 
compile in Compile <<= (compile in Compile).dependsOn(Def.task({ 
    (baseDirectory.value/"target"/"generated_sources").mkdirs() 
})) 
// tell the java compiler to output generated source files to target/generated_sources 
javacOptions in Compile ++= Seq("-s", "target/generated_sources") 

最后,我们需要通过对目录中删除排除告诉IDEA,并非target/一切都应该被忽视, 。进入文件>项目结构>项目设置>模块,点击target目录并取消选择“排除”。或者,右键单击项目选项卡下的target目录,将目录标记为>取消排除。

此时您应该看到编辑器支持工作,如果没有,请运行sbt clean compile以确保生成源代码。 “

+1

”首先,请按照文档中的说明进行操作。“在您的答案中包含重要细节,因此即使链接死亡,您的答案仍然有用。 –