Package doesn't exist error in intelliJ

后端 未结 25 1177
心在旅途
心在旅途 2020-11-28 20:07

I\'m trying to use the barbecue barcode printing library. I have successfully added the library to IntelliJ through project structure add library. Then I imported the packa

相关标签:
25条回答
  • 2020-11-28 20:53

    In my case the problem was that there was a different repository directory configuration in IntelliJ and in settings.xml file.

    Check both repository directories are the same:

    IntelliJ (File > Settings > Build,Execution,Deployment > Build Tools > Maven )

    settings.xml (usually in C:\Users\myuser\.m2 or /home/myuser/.m2)

    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          http://maven.apache.org/xsd/settings-1.0.0.xsd">
    
      ...
      <localRepository>C:\Users\myuser\.m2\repository</localRepository>
      ...
    </settings>
    

    After fixing directories run:

    1. Generate Folders and Update Sources for All Projects

    1. Reimport all maven projects

    0 讨论(0)
  • 2020-11-28 20:54

    In my case the only thing that worked is:

    mvn idea:idea
    

    The good thing is that you don't have to delete .idea folder or .iml files and loose all configuration. Everything will be preserved.

    (Possibly something like gradle idea works for gradle too).

    0 讨论(0)
  • 2020-11-28 20:55

    Quit IntelliJ, remove every .idea directory:

    rm -Rf **/.idea/ 
    

    and restart.

    0 讨论(0)
  • 2020-11-28 20:56
    menu -> build -> Rebuild Project
    

    has worked for me

    (Invalidating caches without this step doesn't help)

    0 讨论(0)
  • 2020-11-28 20:57

    I tried

    1. "Maven > Reimport"
    2. Deleting the .idea directory, and reopening the project.
    3. File -> Invalidate Caches/Restart then Build -> Rebuild Project
    4. Deleting what is inside local .m2 folder, and downloading dependencies again.
    5. Running mvn idea:idea in Maven console (Though this command is obsolete, I had to try.)

    in different combinations.

    But going from Intellij 2020 version to 2019 solved my issue.

    0 讨论(0)
  • 2020-11-28 20:58

    If you added a library to the project structure (rather than via maven, that would be different), be sure it is included as a dependency for the relevant module.

    Project Structure -> Modules -> Dependencies

    0 讨论(0)
提交回复
热议问题