Intellij “java: package org.junit does not exist”

后端 未结 5 1921
遥遥无期
遥遥无期 2021-02-07 17:33

When i try to run my test i get the following Errors: I looked up on google and found somthing on google but this didn\'t help.

Error:(3, 24) java: package org.j         


        
5条回答
  •  有刺的猬
    2021-02-07 18:32

    For anyone ending up here using maven, a couple of things to check:

    • (Sanity check) Have you added junit as a dependency in your pom.xml?
    • Have Intellij accepted your module as a maven module? Try Right clicking the module/project and select Add as Maven Project or perhaps Maven->Reimport
    • Are you using explicit version in your dependency declaration in your pom file? Like 4.12. Try that. (You might not want to this because you want the version to be decided by a parent module. Read on.)
    • Have you remembered to add a dependencyManagement? Maven need it to resolve the correct version number if you don't want to have it explicitly in the current project. For me it refers to the parent project. Like this:
    
        
            
                com.myorg
                myproject-parent
                ${myproject.version}
                import
                pom
            
        
    
    

提交回复
热议问题