2017-03-02 156 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

」首先,請按照文檔中的說明進行操作。「在您的答案中包含重要細節,因此即使鏈接死亡,您的答案仍然有用。 –