如何将其他类路径依赖项传递给maven中的testCompile阶段

我想使用一些外部jar依赖项来编译测试文件,这些依赖项不会出现在pom.xml的依赖项标记中.有没有办法通过配置.像这样的东西 –

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.5</source>
    <target>1.5</target>
  </configuration>
  <executions>
    <execution>
      <id>test-compile</id>
      <configuration>
        <classPathElements>
            <classPathElement>somejar.jar</classPathElement>
        </classPathElements>
      </configuration>
    </execution>

  </executions>
</plugin>

解决方法

试试这个,它包括你项目中的库

<dependency>
        <groupId>mylib</groupId>
        <artifactId>com.mylib</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/src/main/resources/mylib.jar</systemPath>
</dependency>

相关文章

什么是设计模式一套被反复使用、多数人知晓的、经过分类编目...
单一职责原则定义(Single Responsibility Principle,SRP)...
动态代理和CGLib代理分不清吗,看看这篇文章,写的非常好,强...
适配器模式将一个类的接口转换成客户期望的另一个接口,使得...
策略模式定义了一系列算法族,并封装在类中,它们之间可以互...
设计模式讲的是如何编写可扩展、可维护、可读的高质量代码,...