IntellijIDEA not recognizing classes specified in Maven dependencies

后端 未结 24 2286
醉梦人生
醉梦人生 2021-01-30 12:57

I have a project in IntellijIDEA which was created with Maven. I then specified a set of dependencies and external repositories in the Pom.xml file.

The project builds

24条回答
  •  你的背包
    2021-01-30 13:22

    Looks like there are several, valid reasons why intelliJ would ignore a pom file. None of the previous answers worked in my case, so here's what did work, in case someone else runs into this issue:

    In this example, module3 was being completely ignored by IntelliJ. The pom.xml in that directory wasn't even being treated as a maven pom.

    My project structure is like this:

    myProject
        module1
        module2
        module3
    

    BUT, my (simplified) pom structure is like this:

    
        4.0.0
        devs
        myProject
        0.0-SNAPSHOT
        pom
        myProject
    
        
            module1
            module2
        
    
        
            
                CompleteBuildProfile
                
                    module3
                
            
        
    
    

    To fix this, I modified the root element to add in module3 temporarily.

        
            module1
            module2
            module3
        
    

    Next re-import the root pom, and IntelliJ will add the module. When that's done, revert the pom. IntelliJ will ask if you also want to remove module3 from the project structure. Click No.

    Bam! Done. Module3 works and I can run my Integration tests from IntelliJ again :D

提交回复
热议问题