I'm working on a web application based on Spring MVC and Hibernate on Tomcat 8 (both for deployment and local development). The IDE is Spring Tool Suite (which is based on Eclipse).
I want to open a REPL (read-eval-print-loop, like Groovy's, Python's, Ruby's, etc) in the context of my application (while it's running on Tomcat locally), to speed up development by shortening the code -> test feedback loop.
That is, I want to be able to open a shell in the command line (or inside Eclipse) and do something like:
ClientDAO clientDAO = getAutowiredDAOFromSpringSomehow();
Client client = clientDAO.findByID(100);
client.setName("Another name");
clientDAO.save(client);
I can work around this a bit by setting a breakpoint somewhere in a controller and use Eclipse's debugger Display tab to execute arbitrary code, but this is a bit impractical and uncomfortable.
I'm open to using Groovy or Scala's shell if it's more convenient (I obviously still need access to my objects, though).
What are my options?
You may be able to do it using Spring Shell, JShell or BeanShell
Here's a project to embed a repl in an android app using BeanShell
I don't know if it's useful for your use-case but theoretically it should be possible to do this using CRaSH. It's a Shell like Bash on Linux but for your Java-Application and it's possible to create your own commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With