Maven2 + JMeter +具有依赖关系的 JUnit
我想在 JMeter 中运行我的 JUnit 测试。使用 maven-jar-plugin,我可以使用测试创建一个 jar,以便将其放入 JMeter 的类路径 ($JMETER_HOME/lib/junit) 中。问题是我的测试有很多 Maven2 没有放入 jar 中的依赖项,包括项目的主类、其他项目的类和外部库。我该怎么做?
I'd like to run my JUnit tests in JMeter. Using maven-jar-plugin I can create a jar with my tests in order to put it inside the JMeter's classpath ($JMETER_HOME/lib/junit). The problem is that my tests have a lot of dependencies that Maven2 doesn't put into the jar, including the main classes of the project, classes from other projects and external libraries. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 fatjar 插件。
You can use the fatjar plugin.
正如 iwein 提到的,您可以使用 maven-fatjar-plugin ,它将将所有依赖的 JAR 放入您的 JAR 工件中,并创建适当的 MANIFEST 条目以将它们包含在您的类路径中。
另一种选择是您可以使用 maven-shade-plugin ,它会简单地从依赖 JAR 中取出所有“.class”文件,并将它们直接包含在您的 JAR 中。这称为 UBER-JAR。我更喜欢这种方法有几个原因:
As iwein has mentioned, you may use the maven-fatjar-plugin which will put all the dependent JAR's inside of your JAR artifact and create the appropriate MANIFEST entries to include them on your classpath.
Another option is that you can use the maven-shade-plugin which will simply take all of the ".class" files out of the dependecy JARs and include them directly in your JAR. This is called a UBER-JAR. There are a couple of reasons which I prefer this approach: