ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Module compiles, but editor shows compilation issues

2022-06-09 12:34:39  阅读:295  来源: 互联网

标签:sheet compilation share but popover issues answer data se


Module compiles, but editor shows compilation issues 

answered Avatar Arnoud Glimmerveen Created April 18, 2014 11:01  

Since I reorganized my environment today (New project, clean checkout of code from SVN), I have not been able to edit code without the editor showing 'compilation issues' for code that does actually compile.

I have a bunch of Maven modules that compile file using Maven (both from command line and from IDEA) and compilation from IDEA (Build -> Compile/Make) works as well.
But when opening one of the java files, all referenced types that do not originate from my Maven module itself (types from dependencies) are marked as compilation problems ('Cannot resolve symbol XYZ') in the editor. Code completion only reveals types from dependencies when I type the fully qualified name, but a type entered this way is still displayed as a compilation problem (red).

I have no clue what is going wrong here. Has any encountered this behaviour before? I am using IDEA 13.1.1.

2 24 comments SORT BY Avatar Mark Vedder Created April 18, 2014 14:15 Comment actions  

Try invalidating your caches and restarting IDEA (File > Invalidate Cache). Wait for IDEA to re-index your project (Status indicator on lower right status bar). The caches will sometimes become corrupted. This is most likely to occur upon reorganizing a project as you mentioned you did.

4     =========================================================================================================     https://stackoverflow.com/questions/50636628/showing-compile-error-in-intellij-idea-in-editor      

Showing compile error in IntelliJ-idea in editor

Ask Question Asked 4 years ago Modified 1 month ago Viewed 5k times <iframe data-google-container-id="1" data-is-safeframe="true" data-load-complete="true" frameborder="0" height="90" id="google_ads_iframe_/248424177/stackoverflow.com/lb/question-pages_0" marginheight="0" marginwidth="0" scrolling="no" src="https://8f97bfcbc3278a72258dd71e2ed7952f.safeframe.googlesyndication.com/safeframe/1-0-38/html/container.html" title="3rd party ad content" width="728"></iframe> 6

Showing compile error in IntelliJ-idea editor.

mvn clean install 

When run it will build successfully and run code normally. But in editor its unable to resolve those import. Some of the import is showing correctly some of the import it's showing error like Blow enter image description here

and actually, the dependency is present in maven dependency list

enter image description here

In the editor, it showing full of error

I modified build settings, deleted repo, updated maven to the latest version, updated the IntelliJ and tried other suggestion in StackOverflow, still no solution for this problem.

Share Improve this question   edited Nov 12, 2018 at 10:46     asked Jun 1, 2018 at 5:30 user avatar yugi 7741414 silver badges2626 bronze badges Add a comment

6 Answers

7

Try:

  • file > invalidate caches / restart
  • maven tool window -> re-import / refresh: maven tool window
  • check maven settings of IntelliJ: does it point to the same settings.xml and repository as the maven from the command line? IntelliJ is shipped with it's internal maven and might use different settings / repo than your plain maven from the command line.
Share Improve this answer   answered Jun 1, 2018 at 7:38 user avatar BitfullByte 3,59711 gold badge2727 silver badges3333 bronze badges
  •   no ..still facing the same issue. maven settings.xml is pointing to correct maven settings.xml  – yugi  Jun 1, 2018 at 8:39
  • 1 As a last resort, can you try to create your project anew? (e.g. by coping your project folder without the *iml files / .idea folder) and see if you get the same errors. If you don't it's your (intelliJ) project's config. If you still have the issue, it's perhaps an IntelliJ issue itself. Try to see if there is an update or try the EAP. and/or disable all plugins.  – BitfullByte  Jun 1, 2018 at 9:04
  •   yeah .. i will try this  – yugi  Jun 1, 2018 at 9:22
Add a comment <iframe data-google-container-id="4" data-is-safeframe="true" data-load-complete="true" frameborder="0" height="90" id="google_ads_iframe_/248424177/stackoverflow.com/mlb/question-pages_0" marginheight="0" marginwidth="0" scrolling="no" src="https://8f97bfcbc3278a72258dd71e2ed7952f.safeframe.googlesyndication.com/safeframe/1-0-38/html/container.html" title="3rd party ad content" width="728"></iframe> 4  

I believe this issue is related to the way we open this project in IntelliJ Idea as mvn clean install is working fine for you.

While opening the project in IntelliJ, you should open maven project like this:

  • New -> Project from Existing Sources -> Select Project -> Import from External Model (Select maven here) enter image description here
  • After this, if you are asked to override .iml (idea files), you can override them. enter image description here

This should hopefully solve your problem.

Share Improve this answer   answered Jun 1, 2018 at 16:23 user avatar abstractKarshit 1,23511 gold badge1515 silver badges3131 bronze badges Add a comment 0

You can invalidate the cache

file -> invalidate caches and restart 

selecting first two options shown in invalidate cache has worked for, also you might get compile time error in already opened file so, try closing/opening these already opened files which are showing errors.

  1. Clear file system cache and Local History: remove the virtual file system cache together with the information stored in Local History.

    This action might be helpful for troubleshooting purposes when the usual cache invalidation is not enough to solve the problem.
    
    1. Ask before downloading new shared indexes: show a notification prompting you to download new shared indexes as they become available.
    Enabling this option also updates your settings for shared project indexes in Settings/ Preferences | Tools | Shared Indexes.
    
    1. Clear downloaded shared indexes: remove the downloaded shared index files.
Share Improve this answer   answered Jun 25, 2021 at 16:39 user avatar MonishGhutke 5911 silver badge66 bronze badges Add a comment <iframe data-google-container-id="5" data-is-safeframe="true" data-load-complete="true" frameborder="0" height="90" id="google_ads_iframe_/248424177/stackoverflow.com/smlb/question-pages_0" marginheight="0" marginwidth="0" scrolling="no" src="https://8f97bfcbc3278a72258dd71e2ed7952f.safeframe.googlesyndication.com/safeframe/1-0-38/html/container.html" title="3rd party ad content" width="728"></iframe> 0

If it helps, I also had to bump up the heap size for compiler to get past this issue.

enter image description here

Share Improve this answer   answered Oct 21, 2021 at 20:37 user avatar Dravidian 33122 gold badges88 silver badges1818 bronze badges Add a comment 0

Try deleteing the .idea folder under your project, close the project completely and re import fresh and it worked for me.

Share Improve this answer   answered Dec 19, 2021 at 0:20 user avatar user1419261 77977 silver badges55 bronze badges Add a comment 0

I resolved this issue by deleting the local maven repository and restoring the default setting of Intellij

  1. Go to File --> Manage IDE Settings --> Restore Default Settings
  2. Go to File --> Settings --> Build, Execution, Deployment --> Build Tools --> Maven --> Get the Local repository path and delete it.
  3. Open Intellij --> open project --> Go to Terminal --> mvn clean install --> error will disappear after build success
   

标签:sheet,compilation,share,but,popover,issues,answer,data,se
来源: https://www.cnblogs.com/kungfupanda/p/16358863.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有