現在已經有很多類似的問題,但沒有一個提出的解決方案(主要是「清除緩存和重新啓動的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編譯器抱怨「無法解析符號」爲我生成的類。
解決方案我累了爲止
- 增加一箇中間夾/目標/生成來源/ 的protobuf/=>沒有幫助
- 的Invalidate緩存,刪除的項目文件,重新導入,重啓IDE = >沒有幫助
- 的Maven - >重新導入所有項目=>沒有幫助
任何建議?
你試過[這個設置](http://i.imgur.com/Sp18EiK.png)嗎? – CrazyCoder