Unable to import org.springframework package

As stated in this article, I cannot import this package into my web dynamic project using the SpringSource Tool Suite. The Spring Tools โ†’ Add Spring Project Nature command has already been completed. Thanks.

+4
source share
2 answers

What project did you create? Is this a Maven project? If so, you need to make sure that you import the โ€œat leastโ€ spring-context dependency, for example,

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

(or any other version you want to use)

[EDIT]

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

 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 'Spring Project Nature' does not add you dependencies, it only tells the IDE that this project uses Spring.

+3
source

Using maven.it automatically adds the necessary jar files. Otherwise, you need to do this manually. You can look at this http://www.mkyong.com/maven/how-to-convert-java-web-project-to-maven-project/ to transfer an existing project to maven

OR

 You can manually add the necessary jar files. Right click on the spring project>> properties>> java build path>> libraries>>Add jars 

:)

+1
source

Source: https://habr.com/ru/post/1394892/


All Articles