Dependency ‘xxx‘ not found解决方案

问题描述:

项目是通过父子模块分离的方式创建的,因此通过父模块进行版本管理

无论如何切换下载源和配置文件都会出现not found的错误

展示部分的pom依赖如下:


<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.0modelVersion>

    <groupId>com.itheimagroupId>
    <artifactId>healthartifactId>
    <version>1.0-SNAPSHOTversion>

    <packaging>pompackaging>

    <properties>
        <junit.version>4.12junit.version>
        <spring.version>5.0.6.RELEASEspring.version>
        <pagehelper.version>4.1.4pagehelper.version>
        <servlet-api.version>2.5servlet-api.version>
        <mybatis.version>3.4.5mybatis.version>
        <mybatis.spring.version>1.3.1mybatis.spring.version>
        <mysql.version>5.1.32mysql.version>
        <druid.version>1.0.9druid.version>
    properties>

    <dependencyManagement>
        <dependencies>
            
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-contextartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-beansartifactId>
                <version>${spring.version}version>
            dependency>
            
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-webartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-webmvcartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-jdbcartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>junitgroupId>
                <artifactId>junitartifactId>
                <version>4.12version>
            dependency>
    dependencyManagement>
    <build>
        <plugins>
            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.2version>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <encoding>UTF-8encoding>
                configuration>
            plugin>
            <plugin>
                <groupId>org.apache.tomcat.mavengroupId>
                <artifactId>tomcat7-maven-pluginartifactId>
                <version>2.2version>
                <configuration>
                    <path>/path>
                    <port>83port>
                    <uriEncoding>utf-8uriEncoding>
                configuration>
            plugin>
        plugins>
    build>

project>

原因分析:

问题关键:
<dependencyManagement>

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


解决方案:

删除标签再点击刷新依赖,等内容下载完毕之后在将标签添加回去

你可能感兴趣的:(Java踩坑日记,java,maven,spring,mysql,spring,boot)