美文网首页
Dependency ‘xxx‘ not found解决方案

Dependency ‘xxx‘ not found解决方案

作者: flyjar | 来源:发表于2022-08-10 11:05 被阅读0次

问题描述:

项目是通过父子模块分离的方式创建的,因此通过父模块进行版本管理
无论如何切换下载源和配置文件都会出现not found的错误

  • 展示部分的pom依赖如下:
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
            
            <!--解析Excel-->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>easyexcel</artifactId>
                <version>${easyexcel.version}</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-undertow</artifactId>
        </dependency>
    </dependencies>

原因分析:

  • 问题关键: <dependencyManagement>

该标签的作用是父模块对子模块的依赖版本的管理
仅仅是限制子模块中的版本信息
但是重点在于版本的管理 != 调用依赖
既然没有调用依赖就说明这个依赖的jar包就不会被引入到项目中
而不引入项目就意味着IDEA不会自动的把管理中的内容都下载到本地

解决方案:

将<dependencyManagement>里面需要引入信息,放到 <dependencies>里面,引入成功之后,再将信息挪回到<dependencyManagement>中

然后对应的子模块如果哪个要用的话,就在哪个子模块的pom文件中引入。不需要version标签了


    <dependencies>
    

        <dependency>
            <groupId>com.itextpdf.tool</groupId>
            <artifactId>xmlworker</artifactId>
        </dependency>

        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-scratchpad</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>


    </dependencies>

相关文章

网友评论

      本文标题:Dependency ‘xxx‘ not found解决方案

      本文链接:https://www.haomeiwen.com/subject/oyzowrtx.html