IntelliJ 无法识别生成的源

Rob*_*ert 6 intellij-idea maven

已经有很多类似的问题,但没有提出的解决方案(主要是“清除缓存并重新启动 IntelliJ)”解决我的问题。

我有一个导入到 IntelliJ Community Edition 2017.1 的 Maven 项目。我的 Maven 构建会自动从 Google 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>
Run Code Online (Sandbox Code Playgroud)

文件夹/generated-sources/protobuf被正确识别为“generated-sources”,带有蓝色图标和 IntelliJ -> File -> Project Structure -> Modules -> Sources 下生成源的轮子

Maven 目标“编译”也可以正常工作。

但是 IntelliJ“内部”java 编译器为我生成的类抱怨“无法解析符号”。

到目前为止我累了的解决方案

  1. 添加一个中间文件夹 /target/generated-sources/ protobuf / => 没有帮助
  2. 使缓存无效,删除项目文件,重新导入,重新启动 IDE => 没有帮助
  3. Maven -> 重新导入所有项目 => 没有帮助

还有什么建议吗?

Rob*_*ert 8

解决方案:生成的文件太大。不得不增加

idea.max.intellisense.filesize=2500
Run Code Online (Sandbox Code Playgroud)

如下IDE_HOME\bin\idea.properties所述:文件大小超出配置的限制 (2560000),代码洞察功能不可用


Joh*_*nny 6

在 IntelliJ IDEA 2016 及更新版本中,您可以在Help > Edit Custom Properties 中更改此设置。

在旧版本上,没有 GUI 可以做到这一点。但是,如果您按照此处所述编辑 IntelliJ IDEA 平台属性文件,则可以更改它:https : //intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-特性

# 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
Run Code Online (Sandbox Code Playgroud)

不要忘记保存并重新启动IntelliJ IDEA。