错误之处

Posted roni-i

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误之处相关的知识,希望对你有一定的参考价值。

错误之处:如下是 pom.xml 文件,目前只有这个文件部分 dependency 报红影响一些外部jar包导入和其类库方法的使用!

技术图片

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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
    </parent>
    <groupId>com.xuecheng</groupId>
    <artifactId>xc-framework-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <java.version>1.8</java.version>
        <tomcat.version>8.5.28</tomcat.version>
        <spring-boot.version>2.0.1.RELEASE</spring-boot.version>
        <springframework.version>5.0.5.RELEASE</springframework.version>
        <mybatis-spring-boot.version>1.3.1</mybatis-spring-boot.version>
        <mybatis.version>3.4.5</mybatis.version>
        <druid.version>1.1.6</druid.version>
        <mysql-connector-java.version>5.1.45</mysql-connector-java.version>


        <commons-io.version>2.6</commons-io.version>
        <org.apache.commons.io.version>1.3.2</org.apache.commons.io.version>
        <commons-fileupload.version>1.3.3</commons-fileupload.version>
        <commons-codec.version>1.10</commons-codec.version>
        <commons-lang3.version>3.6</commons-lang3.version>
        <okhttp.version>3.9.1</okhttp.version>
        <feign-okhttp.version>8.18.0</feign-okhttp.version>
        <lombok.version>1.16.16</lombok.version>
        <springfox-swagger.version>2.7.0</springfox-swagger.version>
        <fastjson.version>1.2.30</fastjson.version>
        <fastdfs-client-java.version>1.27.0.0</fastdfs-client-java.version>
        <mysql-connector-java.version>5.1.40</mysql-connector-java.version>
        <elasticsearch.version>6.2.1</elasticsearch.version>
        <guava.version>24.0-jre</guava.version>
    </properties>
    <!--test-->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>$mysql-connector-java.version</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>$mybatis-spring-boot.version</version>
            </dependency>
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>1.2.4</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>$druid.version</version>
            </dependency>

            <dependency>
                <groupId>com.squareup.okhttp3</groupId>
                <artifactId>okhttp</artifactId>
                <version>$okhttp.version</version>
            </dependency>
            <dependency>
                <groupId>com.netflix.feign</groupId>
                <artifactId>feign-okhttp</artifactId>
                <version>$feign-okhttp.version</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>$commons-io.version</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-io</artifactId>
                <version>$org.apache.commons.io.version</version>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>$commons-fileupload.version</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>$commons-codec.version</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>$commons-lang3.version</version>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>$lombok.version</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>$springfox-swagger.version</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>$springfox-swagger.version</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>$fastjson.version</version>
            </dependency>
            <dependency>
                <groupId>net.oschina.zcx7878</groupId>
                <artifactId>fastdfs-client-java</artifactId>
                <version>$fastdfs-client-java.version</version>
            </dependency>

            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>elasticsearch-rest-high-level-client</artifactId>
                <version>$elasticsearch.version</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>$elasticsearch.version</version>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>$guava.version</version>
            </dependency>

        </dependencies>
    </dependencyManagement>
    <build>
        <finalName>$project.artifactId</finalName>
        <plugins>
            <!-- &lt;!&ndash; 资源文件拷贝插件 &ndash;&gt;
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-resources-plugin</artifactId>
                 <configuration>
                     <encoding>UTF-8</encoding>
                 </configuration>
             </plugin>-->
            <!-- java编译插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

具体信息:IDEA 15.0.6 + Spring Boot 2.0.1——》mysql、pagehelper、druid等部分依赖包在 External Libraries 没看到 maven 自动下载的 JAR 包

自我判断:疑似 maven 根本没去自动导入缺失的部分 jar 包——》为什么导入不了部分 jar 包?——》

自我解决1:首先怀疑联网中断问题——》右侧蓝色 maven project 进行 clean + install 并且 reimport (没用)

自我解决2:怀着悲壮的心情,将原 External Libraries 的 Maven 下载的 jar 包备份——》然后找到一份已经下载了(具备了)所有需要的 jar 包的 Libraries 文件夹并且【替换】原 Libraries ——》然而 点击maven 的 reimport,发现又变为原来的 Libraries !

自我解决3:把 lib 里面的 jar 包 + target 文件全部删除——》reimport——》结果同上

技术图片

震惊!有部分写在dependency里面却得不到maven自动下载的jar包?

技术图片

神奇!左侧 maven 明明没有自动导入 apache.commons.io ,右侧居然没报错?

技术图片

好像是 jar 的 版本问题,真就是版本问题阿???

以上是关于错误之处的主要内容,如果未能解决你的问题,请参考以下文章

为啥这个代码片段说包含错误?

在下面的代码片段中的剩余 ='passthrough' 处的代码中出现语法错误

如何向 ViewPager 提供许多片段并避免错误代码?

错误代码:错误域 = NSCocoaErrorDomain 代码 = 3840“JSON 文本没有以数组或对象和允许未设置片段的选项开头。”

片段事务中的实例化错误

为啥代码片段在 matplotlib 2.0.2 上运行良好,但在 matplotlib 2.1.0 上引发错误