How to create a CLI like Spring Shell in Java EE application without spring framework?

こ雲淡風輕ζ 提交于 2019-12-12 03:08:26

问题


I used Spring shell in my project, which works very well.

Now we have a Java EE project on the JBoss application server. I would like to have a good CLI, just like the Spring shell. How can this be done?


回答1:


As far as I understand your request, Spring Shell is not meant for this. Spring Shell is somewhat tied to running in an actual terminal, leveraging JLine. Another implementation could be written (similar to the "running in IDE" approach) that scans for MethodTargets and runs them, taking input from your (custom) webapp.

Maybe http://www.crashub.org/ is more tailored to what you're asking for.




回答2:


I would expose all the JBoss services API via REST, using Swagger. Then generate the swagger.json and import it in Swagger Editor, generate automatically the Java client and invoke it from the Spring Shell client. I know it's a bit roundaboutish, but unfortunately as now I am not aware of how to integrate Spring Shell in a Java EE application. You can even automate the generation of the Java Client https://www.baeldung.com/spring-boot-rest-client-swagger-codegen



来源:https://stackoverflow.com/questions/34409711/how-to-create-a-cli-like-spring-shell-in-java-ee-application-without-spring-fram

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