“The import org.springframework cannot be resolved.”

后端 未结 17 628
傲寒
傲寒 2020-12-13 12:44

Here is my POM.xml file:


    
        1.6
        3.2.2.RELEAS         


        
相关标签:
17条回答
  • 2020-12-13 13:21

    Add these dependencies

    </dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>4.3.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.7.RELEASE</version>
        </dependency>
    </dependencies>
    
    0 讨论(0)
  • 2020-12-13 13:22

    You need to follow a few steps to debug properly.

    1) mvn clean dependency:tree Take a look at the output to see exactly what you get and verify your dependencies are all there.

    2) mvn clean compile. Does this fail? If not does that mean you only get the error in Eclipse?

    You mentioned in a comment "And I run both commands above but I am getting this error". Did mvn clean compile work? Or did you get an error for that as well? If it worked then it's just an IDE problem and I'd look at the m2eclipse plugin. Better still, use IntelliJ as the free version has better maven support than Eclipse ;-)

    Some style things ...

    People often add too many dependencies in their pom file when they don't need to. If you take a look at a couple of links in mavenrepository.com you can see that spring-oxm and spring-jdbc both depend on spring-core so you don't need to add that explicitly (for example). mvn clean dependency:tree will show you what is coming in after all of that, but this is more tidying.

    spring-batch-test should be test scope.

    0 讨论(0)
  • 2020-12-13 13:22

    The solution that worked for me was to right click on the project --> Maven --> Update Project then click OK.

    0 讨论(0)
  • 2020-12-13 13:22

    There are few steps you can follow

    1. remove repository folder

      C:/Users/user_name/.m2

    2. Then run command using IDE terminal or open cmd in your project folder

      mvn clean install

    3. Restart your ide

    4. If not solve your problem then run this command

      mvn idea:idea

    0 讨论(0)
  • 2020-12-13 13:29

    org.springframework.beans.factory.support.beannamegenerator , was my error. I did a maven clean, maven build etc., which was not useful and I found that my .m2 folder is not present in my eclipse installation folder. I found the .m2 folder out side of the eclipse folder which I pasted in the eclipse folder and then in eclipse I happened to do this :-

    Open configure build path maven Java EE integration Select Maven archiver generates files under the build directory apply and close

    My project is up and running now.

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