Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java Spring import error

Tags:

java

spring

I've downloaded spring-framework-4.1.6.RELEASE from http://maven.springframework.org/release/org/springframework/spring/

Then I followed the Spring Website http://spring.io/guides/gs/rest-service/ to start a project,but I found there is a problem in it.

//The import org.springframework.boot cannot be resolved
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

It seems like that it can't find the jar files so can't import it,but I've add all jar files to build path.
How can I solve it? Is Spring and SpringFramework the same one?

like image 262
weaver Avatar asked Dec 06 '22 21:12

weaver


1 Answers

It looks like you are trying to access classes which are part of the Spring Boot project, it might be the case that your Spring libraries do not contain the Spring Boot project related libraries.

Naturally I'd recommend for you to import it via Maven or Gradle as suggested by the Spring Boot Quickstart.

But if you want to add it manually, the latest release jar currently for SpringApplication is spring-boot-1.2.3.RELEASE.jar

Find it HERE

And the SpringBootApplication class is found within spring-boot-autoconfigure-1.2.3.RELEASE.jar

Find it HERE

So check if you have similar jars among your current ones and download them if not, also remember since you are dealing with dependencies manually, it's quite possible that these two new libraries will have dependencies of their own and you'll have to accommodate to them as well.

like image 110
Ceiling Gecko Avatar answered Dec 21 '22 13:12

Ceiling Gecko