intellij-idea IntelliJ无法识别生成的源

wz1wpwve  于 2022-11-01  发布在  其他
关注(0)|答案(4)|浏览(298)

已经有很多类似的问题,但提出的解决方案(主要是“清除缓存并重新启动IntelliJ”)都没有解决我的问题。
我有一个导入到IntelliJ Community Edition 2017.1中的Maven项目。我的Maven构建会自动根据Google protobuf规范创建一些Java源代码。
摘录自pom.xml

  1. <plugin>
  2. <groupId>com.github.os72</groupId>
  3. <artifactId>protoc-jar-maven-plugin</artifactId>
  4. <version>3.2.0</version>
  5. <executions>
  6. <execution>
  7. <phase>generate-sources</phase>
  8. <goals>
  9. <goal>run</goal>
  10. </goals>
  11. <configuration>
  12. <protocVersion>3.1.0</protocVersion> <!-- 2.4.1, 2.5.0, 2.6.1, 3.1.0 -->
  13. <inputDirectories>
  14. <include>src/main/protobuf</include>
  15. </inputDirectories>
  16. <outputDirectory>${project.build.directory}/generated-sources/protobuf</outputDirectory>
  17. </configuration>
  18. </execution>
  19. </executions>
  20. </plugin>

文件夹 /generated-sources/protobuf 被正确识别为“generated-sources”(带有蓝色图标),并在IntelliJ -〉文件-〉项目结构-〉模块-〉源下带有生成源的滚轮
maven目标“compile”也工作得很好。
但是IntelliJ“内部”java编译器对我生成的类抱怨“无法解析符号”。
解我累为止
1.添加一个中间文件夹/target/generated-sources/protobuf/ =〉没有帮助
1.使缓存无效,删除项目文件,重新导入,重新启动IDE =〉没有帮助

  1. Maven -〉重新导入所有项目=〉没有帮助
    还有什么建议吗?
nzrxty8p

nzrxty8p1#

在IntelliJ IDEA 2016和更新版本中,您可以在帮助〉编辑自定义属性中更改此设置。
在旧版本中,没有GUI来执行此操作。但是,如果您编辑IntelliJ IDEA平台属性文件,则可以更改它,如下所述:https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties

  1. # Maximum file size (kilobytes) IDE should provide code assistance for.
  2. idea.max.intellisense.filesize=50000
  3. # Maximum file size (kilobytes) IDE is able to open.
  4. idea.max.content.load.filesize=50000

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

hmmo2u0o

hmmo2u0o2#

解决方案:生成的文件太大。必须增加

  1. idea.max.intellisense.filesize=2500

IDE_HOME\bin\idea.properties中,如下所述:File size exceeds configured limit (2560000), code insight features not available

ddarikpa

ddarikpa3#

尝试添加

  1. <goal>compile</goal>
  2. <goal>compile-custom</goal>

到目标节点。

eimct9ow

eimct9ow4#

如果生成的文件大小不是您的问题;请查看上面的@CrazyCoder注解。2在插件配置中,将执行阶段更改为 process-resources

  1. <executions>
  2. <execution>
  3. <phase>process-resources</phase>
  4. <goals>
  5. <goal>compile</goal>
  6. <goal>compile-custom</goal>
  7. </goals>
  8. </execution>
  9. </executions>

相关问题