添加 maven 依赖 当你已经创建好 springboot 应用后,将 picocli 的依赖加入到 pom.xml 中 <dependency> <groupId>info.picocli</groupId> <artifactId>picocli-spring-boot-starter</artifactId> <version>4.6.3</version> </dependency> 修改 springboot 主程序 将你的 springboot 主程序修改为实现了ApplicationRunner接口,并将主程序命令定义为helper package top.yjp.testing; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import picocli.CommandLine; import top.yjp.testing.helper.cmd.DemoCommand; import javax.annotation.Resource; @SpringBootApplication(proxyBeanMethods = false) @Slf4j @CommandLine.Command( name = "helper", description = "自动化测试帮助程序 ", mixinStandardHelpOptions = true, version = "1.0.1", subcommands = {DemoCommand.class} )……

阅读全文