How to execute Cucumber Spring Boot Packaged Jar from command line?

自闭症网瘾萝莉.ら 提交于 2019-12-11 02:34:36

问题


I am fairly new to cucumber-jvm world. Trying to package cucumber spring boot app as Jar. app runs fine from Eclipse. But when I package as executable jar it fails with Exception :

Exception in Main Thread, No backend Module found. Make sure that you have backend module on CLASSPATH. Kindly help. Thank you.


回答1:


From: https://github.com/cucumber/cucumber-jvm/issues/1320

SpringBoot uses a nested jar structure that requires the use of ApplicationContext.getResources to access it transparently. You'll have to create your own instance of the Cucumber runtime and provide it a class loader and resource loader that use the ApplicationContext.




回答2:


Using Gradle, place the Cucumber artifacts (ie features, step implementations, etc) into a subproject, eg my-cucumber-tests, separate from the Spring Boot app.

Then in the Spring Boot app's build.gradle, add:

bootJar {
  // make backend, features, and steps available to Cucumber at runtime
  requiresUnpack '**/my-cucumber-tests-*.jar', '**/cucumber-java-*.jar'
}


来源:https://stackoverflow.com/questions/50263949/how-to-execute-cucumber-spring-boot-packaged-jar-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!