You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot报错:package org.springframework.boot不存在求助

解决Spring Boot中package org.springframework.boot不存在的报错

你用的Spring Boot 3.0.5版本最低要求JDK 17,但pom里配置的编译版本是JDK8,版本不兼容导致依赖无法正确引入,这就是报错的核心原因。下面给两种可行的解决办法:

方法一:升级JDK到17及以上

  1. 安装JDK 17或更高版本
  2. 修改pom.xml里的编译版本配置:
<properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
  1. 在IDE中把项目的JDK版本设置为17
  2. 执行Maven命令刷新依赖:mvn clean install,或者在IDE里点击「重新导入Maven项目」

方法二:降级Spring Boot到支持JDK8的版本

Spring Boot 2.7.x系列是最后支持JDK8的稳定版本,修改pom.xml里的parent版本:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.15</version> <!-- 该版本兼容JDK8 -->
</parent>

之后同样执行mvn clean install或刷新Maven依赖即可。

你的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>io.github.yuriney</groupId>
    <artifactId>vendas</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.5</version>
    </parent>

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

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

你的启动类代码:

package io.github.yuriney;

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

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

内容的提问来源于stack exchange,提问作者Yuri Martins

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 12:03:21