IntelliJ中的依赖突然失效。

移动开发 2026-07-07

我突然在IntelliJ的 pom.xml中遇到了这些依赖失败。

Unresolved dependency: 'org.springframework.boot:spring-boot-starter-web:jar:4.1.0-M4'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-jackson:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-jackson:jar:4.0.0'
Unresolved dependency: 'tools.jackson.core:jackson-databind:jar:3.0.2'
Unresolved dependency: 'com.fasterxml.jackson.core:jackson-annotations:jar:2.20'
Unresolved dependency: 'tools.jackson.core:jackson-core:jar:3.0.2'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-tomcat:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-tomcat-runtime:jar:4.0.0'
Unresolved dependency: 'org.apache.tomcat.embed:tomcat-embed-core:jar:11.0.14'
Unresolved dependency: 'org.apache.tomcat.embed:tomcat-embed-el:jar:11.0.14'
Unresolved dependency: 'org.apache.tomcat.embed:tomcat-embed-websocket:jar:11.0.14'
Unresolved dependency: 'org.springframework.boot:spring-boot-tomcat:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-http-converter:jar:4.0.0'
Unresolved dependency: 'org.springframework:spring-web:jar:7.0.1'
Unresolved dependency: 'org.springframework:spring-beans:jar:7.0.1'
Unresolved dependency: 'io.micrometer:micrometer-observation:jar:1.16.0'
Unresolved dependency: 'io.micrometer:micrometer-commons:jar:1.16.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-webmvc:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-servlet:jar:4.0.0'
Unresolved dependency: 'org.springframework:spring-webmvc:jar:7.0.1'
Unresolved dependency: 'org.springframework:spring-aop:jar:7.0.1'
Unresolved dependency: 'org.springframework:spring-expression:jar:7.0.1'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-webmvc-test:jar:4.1.0-M4'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-jackson-test:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-webmvc:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-webmvc-test:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-web-server:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-resttestclient:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-restclient:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-http-client:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-thymeleaf:jar:4.1.0-M4'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-logging:jar:4.0.0'
Unresolved dependency: 'ch.qos.logback:logback-classic:jar:1.5.21'
Unresolved dependency: 'ch.qos.logback:logback-core:jar:1.5.21'
Unresolved dependency: 'org.apache.logging.log4j:log4j-to-slf4j:jar:2.25.2'
Unresolved dependency: 'org.apache.logging.log4j:log4j-api:jar:2.25.2'
Unresolved dependency: 'org.slf4j:jul-to-slf4j:jar:2.0.17'
Unresolved dependency: 'jakarta.annotation:jakarta.annotation-api:jar:3.0.0'
Unresolved dependency: 'org.yaml:snakeyaml:jar:2.5'
Unresolved dependency: 'org.springframework.boot:spring-boot-thymeleaf:jar:4.0.0'
Unresolved dependency: 'org.thymeleaf:thymeleaf-spring6:jar:3.1.3.RELEASE'
Unresolved dependency: 'org.thymeleaf:thymeleaf:jar:3.1.3.RELEASE'
Unresolved dependency: 'org.attoparser:attoparser:jar:2.0.7.RELEASE'
Unresolved dependency: 'org.unbescape:unbescape:jar:1.1.6.RELEASE'
Unresolved dependency: 'org.mockito:mockito-core:jar:5.23.0'
Unresolved dependency: 'net.bytebuddy:byte-buddy:jar:1.17.8'
Unresolved dependency: 'net.bytebuddy:byte-buddy-agent:jar:1.17.8'
Unresolved dependency: 'org.objenesis:objenesis:jar:3.3'
Unresolved dependency: 'org.springframework.boot:spring-boot-autoconfigure:jar:4.1.0-M4'
Unresolved dependency: 'org.springframework.boot:spring-boot:jar:4.0.0'
Unresolved dependency: 'org.springframework:spring-context:jar:7.0.1'
Unresolved dependency: 'com.mysql:mysql-connector-j:jar:9.7.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-starter-test:jar:4.1.0-M4'
Unresolved dependency: 'org.springframework.boot:spring-boot-test:jar:4.0.0'
Unresolved dependency: 'org.springframework.boot:spring-boot-test-autoconfigure:jar:4.0.0'
Unresolved dependency: 'com.jayway.jsonpath:json-path:jar:2.9.0'
Unresolved dependency: 'org.slf4j:slf4j-api:jar:2.0.17'
Unresolved dependency: 'jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.4'
Unresolved dependency: 'jakarta.activation:jakarta.activation-api:jar:2.1.4'
Unresolved dependency: 'net.minidev:json-smart:jar:2.6.0'
Unresolved dependency: 'net.minidev:accessors-smart:jar:2.6.0'
Unresolved dependency: 'org.ow2.asm:asm:jar:9.7.1'
Unresolved dependency: 'org.assertj:assertj-core:jar:3.27.6'
Unresolved dependency: 'org.awaitility:awaitility:jar:4.3.0'
Unresolved dependency: 'org.hamcrest:hamcrest:jar:3.0'
Unresolved dependency: 'org.junit.jupiter:junit-jupiter:jar:6.0.1'
Unresolved dependency: 'org.junit.jupiter:junit-jupiter-api:jar:6.0.1'
Unresolved dependency: 'org.opentest4j:opentest4j:jar:1.3.0'
Unresolved dependency: 'org.junit.platform:junit-platform-commons:jar:6.0.1'
Unresolved dependency: 'org.apiguardian:apiguardian-api:jar:1.1.2'
Unresolved dependency: 'org.junit.jupiter:junit-jupiter-params:jar:6.0.1'
Unresolved dependency: 'org.junit.jupiter:junit-jupiter-engine:jar:6.0.1'
Unresolved dependency: 'org.junit.platform:junit-platform-engine:jar:6.0.1'
Unresolved dependency: 'org.mockito:mockito-junit-jupiter:jar:5.20.0'
Unresolved dependency: 'org.skyscreamer:jsonassert:jar:1.5.3'
Unresolved dependency: 'com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1'
Unresolved dependency: 'org.springframework:spring-core:jar:7.0.1'
Unresolved dependency: 'commons-logging:commons-logging:jar:1.3.5'
Unresolved dependency: 'org.jspecify:jspecify:jar:1.0.0'
Unresolved dependency: 'org.springframework:spring-test:jar:7.0.1'
Unresolved dependency: 'org.xmlunit:xmlunit-core:jar:2.10.4'
Unresolved plugin: 'org.springframework.boot:spring-boot-maven-plugin:4.0.0'
Unresolved plugin: 'org.apache.maven.plugins:maven-clean-plugin:3.5.0'
Unresolved plugin: 'org.apache.maven.plugins:maven-resources-plugin:3.3.1'
Unresolved plugin: 'org.apache.maven.plugins:maven-jar-plugin:3.4.2'
Unresolved plugin: 'org.apache.maven.plugins:maven-compiler-plugin:3.14.1'
Unresolved plugin: 'org.apache.maven.plugins:maven-surefire-plugin:3.5.4'
Unresolved plugin: 'org.apache.maven.plugins:maven-install-plugin:3.1.4'
Unresolved plugin: 'org.apache.maven.plugins:maven-deploy-plugin:3.1.4'
Unresolved plugin: 'org.apache.maven.plugins:maven-site-plugin:3.12.1'

这是我的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 https://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>4.0.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.codefinity</groupId>
    <artifactId>spring-boot-exm-shop</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-boot-exm-shop</name>
    <description>spring-boot-exm-shop</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>25</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>4.1.0-M4</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webmvc-test</artifactId>
            <version>4.1.0-M4</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>4.1.0-M4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.23.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>4.1.0-M4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>9.7.0</version>
            <scope>compile</scope>
        </dependency>

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

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

</project>

这些来自Codefinity的仓库本来可以工作,但后来我为了看Udemy的视频开始使用Eclipse,删除了Eclipse的 .m2文件夹,结果在IntelliJ里就出现了这个错误。我是不是需要逐个手动更新每个依赖?这是IntelliJ的某种配置问题,还是怎么回事?这已经出现在我所有的IntelliJ项目中。我为每个项目的项目结构也都设为了Java 25。

解决方案

对我来说,解决的第一步是在命令行中运行mvn clean verify,确实IntelliJ有一些内部缓存,可能会对依赖产生某种误导。

如果mvn clean verify能成功,那么你可以在IDE里看看是否好一点;如果没有,我建议使用Maven选项,例如“同步项目”、“生成源并更新文件夹”,或者作为最后的手段“取消链接Maven项目”,然后重新链接一次。

另外一个更极端的选项是关闭IDE,删除.idea文件夹(IDE存放关于你项目的所有信息的地方),然后把该项目以新工程的方式重新打开。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章