Spring Boot application can't resolve the org.springframework.boot package

前端 未结 17 1823
半阙折子戏
半阙折子戏 2020-12-29 19:34

I have set up a spring boot project using the Spring Initializer, I tried several times to create a new project or play with the dependencies, everything seems to be in plac

相关标签:
17条回答
  • 2020-12-29 20:18

    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.

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

    Delete the repository folder from "C:\Users\usename.m2" and create again or update maven project.

    0 讨论(0)
  • 2020-12-29 20:22

    Try this, It might work for you too.

    1. Open command prompt and go to the project folder.
    2. Build project (For Maven, Run mvn clean install)
    3. After successful build,
      • Open your project on any IDE (intellij / eclipse).
      • Restart your IDE incase it is already opened.

    This worked for me on both v1.5 and v2.1

    0 讨论(0)
  • 2020-12-29 20:22

    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

    0 讨论(0)
  • 2020-12-29 20:22

    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>
    
    0 讨论(0)
  • 2020-12-29 20:24

    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

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