2017-04-25 51 views
1

現在已經有很多類似的問題,但沒有一個提出的解決方案(主要是「清除緩存和重新啓動的IntelliJ)的解決我的問題。的IntelliJ不能識別產生源

我有導入的IntelliJ社區Maven項目版2017.1。我的Maven構建自動從谷歌protobuf的規範產生了一些Java源代碼。

摘自的pom.xml

  <plugin> 
      <groupId>com.github.os72</groupId> 
      <artifactId>protoc-jar-maven-plugin</artifactId> 
      <version>3.2.0</version> 
      <executions> 
       <execution> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <protocVersion>3.1.0</protocVersion> <!-- 2.4.1, 2.5.0, 2.6.1, 3.1.0 --> 
         <inputDirectories> 
          <include>src/main/protobuf</include> 
         </inputDirectories> 
         <outputDirectory>${project.build.directory}/generated-sources/protobuf</outputDirectory> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

文件夾/generated-sources/protobuf在IntelliJ - >文件 - >項目結構 - >模塊 - >源代碼中被正確識別爲帶有藍色圖標和生成源的「generated-sources」

maven目標「編譯「也很好。

但IntelliJ「內部」java編譯器抱怨「無法解析符號」爲我生成的類。

解決方案我累了爲止

  1. 增加一箇中間夾/目標/生成來源/ 的protobuf/=>沒有幫助
  2. 的Invalidate緩存,刪除的項目文件,重新導入,重啓IDE = >沒有幫助
  3. 的Maven - >重新導入所有項目=>沒有幫助

任何建議?

+0

你試過[這個設置](http://i.imgur.com/Sp18EiK.png)嗎? – CrazyCoder

回答

0

嘗試增加

<goal>compile</goal> 
<goal>compile-custom</goal> 

到目標節點。

0

在IntelliJ IDEA的2016和較新的,你可以更改幫助>編輯自定義屬性此設置。

在舊版本上,沒有GUI來執行此操作。但是,這裏描述你可以改變它,如果你編輯的IntelliJ IDEA平臺屬性文件:https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties

# Maximum file size (kilobytes) IDE should provide code assistance for. 
idea.max.intellisense.filesize=50000 

# Maximum file size (kilobytes) IDE is able to open. 
idea.max.content.load.filesize=50000 

不要忘記保存並重啓 IntelliJ IDEA的。