Search code examples
springspring-nature

org.springframework package cannot be imported


As the topic says I cannot import this package in my web dynamic project using SpringSource Tool Suite.The command Spring Tools --> Add Spring Project Nature has been already executed. Thank you.


Solution

  • What kind of project did you create? Is it a Maven project? If so, you need to make sure that you are importing 'at least' the spring-context dependency like so

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.1.0.RELEASE</version>
        <scope>runtime</scope>
    </dependency>
    

    (or whatever version you want to use)

    [EDIT]

    Since as you say, you are using a Dynamic Web Project through this example -> http://www.vaannila.com/spring/spring-mvc-tutorial-1.html, you need to physically add the following jar files to your WEB-INF/lib folder

    antlr-runtime-3.0
    commons-logging-1.0.4
    org.springframework.asm-3.0.0.M3
    org.springframework.beans-3.0.0.M3
    org.springframework.context-3.0.0.M3
    org.springframework.context.support-3.0.0.M3
    org.springframework.core-3.0.0.M3
    org.springframework.expression-3.0.0.M3
    org.springframework.web-3.0.0.M3
    org.springframework.web.servlet-3.0.0.M3
    

    You should have the following:

    lib folder

    Adding the 'Spring Project Nature' does not add the dependencies for you, but only instructs the IDE that this project is using Spring.