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

前端 未结 17 1822
半阙折子戏
半阙折子戏 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条回答
  • It's not necessary to remove relative path. Just change the version parent of springframework boot. The following version 2.1.2 works successfully.

    <?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.2.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.appsdeveloperblog.app.ws</groupId>
        <artifactId>mobile-app-ws</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>mobile-app-ws</name>
        <description>Demo project for Spring Boot</description>
    
        <properties>
            <java.version>1.8</java.version>
        </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>
            <dependency>
                <groupId>com.appsdeveloperblog.app.ws</groupId>
                <artifactId>mobile-app-ws</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    
    </project>
    
    0 讨论(0)
  • 2020-12-29 20:27

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

    Solution is change the version of Spring in file pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>
    
    0 讨论(0)
  • 2020-12-29 20:29

    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.
    2. Choose any jar and mousehover .. it will show the local repository location. generally it is : user/.m2/repository/....
    3. Go to the location . and remove the repository folder contains.
    4. Now right click on your project .. do Maven --> maven update.
      This will solve your dependencies problem . as Maven will try to download all the items again from repository and build the project.
    0 讨论(0)
  • 2020-12-29 20:30

    After upgrading Spring boot to the latest version - 2.3.3.RELEASE. I also got this error - Cannot resolve org.springframework.boot:spring-boot-starter-test:unknown. Maven clean install, updating maven project, cleaning cache do not help.
    The solution was adding version placeholder from spring boot parent pom:

     <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-test</artifactId>
       <version>${spring-boot.version}</version>
       <scope>test</scope>
     </dependency>
    
    0 讨论(0)
提交回复
热议问题