• Classpath resource [/data/department/createDepartment.csv] does not exist


    一、问题现象

      在做自动化的时候,想使用参数化功能,数据源为CSV,但是遇到以下问题

    Classpath resource [/data/department/createDepartment.csv] does not exist
    org.junit.platform.commons.PreconditionViolationException: Classpath resource [/data/department/createDepartment.csv] does not exist
    
        at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:296)
        at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
        at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
        at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
        at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
        Suppressed: org.junit.platform.commons.PreconditionViolationException: Configuration error: You must configure at least one set of arguments for this @ParameterizedTest
            at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:281)
            at org.junit.jupiter.params.ParameterizedTestExtension.lambda$provideTestTemplateInvocationContexts$6(ParameterizedTestExtension.java:90)
            at java.util.stream.AbstractPipeline.close(AbstractPipeline.java:323)
            at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271)
            ... 49 more

    二、问题定位

      maven项目的classPath路径下没有文件/data/department/createDepartment.csv,即maven的classPath在 “targetclasses”目录下

    三、原因分析

    maven默认只会加载classPath同级目录下文件,其他的需要重新设置

    四、解决方案

    1、选中项目工程,右键,选择Open  Moudle Settings,选择Resources,点击apply

      ===========================================================================================

    2、在pom文件的bulid标签配置<resources>(极力推荐)

            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.properties</include>
                        <include>**/*.xml</include>
                    </includes>
                    <!--是否替换资源中的属性-->
                    <filtering>false</filtering>
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**/*.properties</include>
                        <include>**/*.xml</include>
                        <include>**/*.yml</include>
                        <include>**/Dockerfile</include>
                        <include>**/*.xlsx</include>
                        <include>**/*.csv</include>
                    </includes>
                    <!--是否替换资源中的属性-->
                    <filtering>false</filtering>
                </resource>
            </resources>

    五、总结

      此种问题,是因为还不够了解maven,看来还是需要多研究研究

    推荐博客:

    maven打包resources配置

    maven resources官网

    知道、想到、做到、得到
  • 相关阅读:
    laravel5.1框架简介及安装
    数据结构之队列定义及基本操作实现
    PHP之闭包详解
    数据结构之栈定义及基本操作实现
    PHP之MVC微型框架简单搭建
    对web应用中单一入口模式的理解及php实现
    php面向对象编程学习之高级特性
    数据结构之链表定义及基本操作实现
    数据结构之数组定义及基本操作
    感悟
  • 原文地址:https://www.cnblogs.com/Durant0420/p/14993464.html
Copyright © 2020-2023  润新知