maven assbmely打包方式把项目中引入的test类依赖 打入jar包
时间: 2024-05-02 12:22:26 浏览: 114
你可以在 Maven 插件中使用 `<includeTestDependencies>true</includeTestDependencies>` 来将测试依赖项打包至 jar 包中,示例如下:
```xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<includeTestDependencies>true</includeTestDependencies>
</configuration>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
```
这样,打包时将会包含测试的依赖项。
阅读全文