Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 354 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spring Boot application can't resolve the org.springframework.boot package

#1
I have set up a spring boot project using the [Spring Initializer](

[To see links please register here]

), I tried several times to create a new project or play with the dependencies, everything seems to be in place.

I am using STS(Spring Tool Suite) and it shows errors about the imports from the`org.springframework.boot` package. Running the application throws an exception:

> Exception in thread "main" java.lang.Error: Unresolved compilation
> problem: SpringApplication cannot be resolved.


com.example.DemoApplication:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

[To see links please register here]

;
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>demo</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<start-class>com.example.DemoApplication</start-class>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>

I am using Java 1.8 with STS.
Reply

#2
When you run your application as an jar, your `Manifest.MF` file should know which class has the main method.

To add this information when SpringBoot compiles your code, add `start-class` property on your pom file.

E.g.:

<properties>
<start-class>com.example.DemoApplication</start-class>
</properties>
Reply

#3
Right button on project -> Maven -> Update Project

then check "Force update of Snapshots/Releases"
Reply

#4
change the version of spring boot parent

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
Reply

#5
I had the same problem when I was trying to work with a basic spring boot app. I tried to use the latest spring-boot version from the official [spring-boot site](

[To see links please register here]

).

As on today, the latest version is **1.5.4.RELEASE**. But I keep getting compilation issues on my eclipse IDE irrespective of multiple cleanups to the project. I lowered the version of spring-boot to **1.5.3.RELEASE** and it simply *worked* !! Some of my earlier projects were using the old version which drove me to try this option.
Reply

#6
From your pom.xml, try to remove spring repository entries, per default will download from maven repository. I have tried with 1.5.6.RELEASE and worked very well.
Reply

#7
**I have encountered the same problem while my first Spring boot application.**

In tutorial i could see following dependency to start sample application

- Spring Boot 1.4.2.RELEASE
- Maven 3
- java 8

I have done the same, my Spring STS is recognizing all class but when i am annotating my main class with @SpringBootApplication it's not recognizing this class whereas i could see jar was available in the class path.

**I have following to resolve issues**

- Replaced my Spring Boot 1.4.2.RELEASE to 1.5.3.RELEASE
- Right click on project and -> Maven-> Download Resources
- right click on project -> Maven-> Update project

After that it worked.

Thanks

Reply

#8
If the below step not work:

Replaced my Spring Boot 1.4.2.RELEASE to 1.5.10.RELEASE

- Right click on project and -> Maven-> Download Resources
- right click on project -> Maven-> Update project

The reason for this error might be multiple version of the same is downloaded into your maven local repository folder.

So follow below steps to clear all existing repository jars and download all from beginning based on dependencies defined in your POM.xml..

1. Go to build path . Check Maven Repository in the libraries added section.<br>
2. Choose any jar and mousehover .. it will show the local repository location.
generally it is : user/.m2/repository/....<br>
3. Go to the location . and remove the repository folder contains.<br>
4. Now right click on your project .. do Maven --> maven update. <br>
This will solve your dependencies problem . as Maven will try to download all the items again from repository and build the project.
Reply

#9
Maybe there is a problem with the JAR files in the local Maven repository. Try deleting the .m2/repository folder and hit Maven -> Update Project... another time to trigger Maven to download the dependencies again. I tried it and it worked for me.
Reply

#10
In my project, updated the dependency on spring-boot-starter-parent from 2.0.0.release to 2.0.5.relese.
Doing this resolved the issue The import org.springframework.boot.SpringApplication cannot be resolved
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through