简体   繁体   中英

Java Rest framework + server to expose service to Ruby on Rails

I have a very small Java codebase that I would like to expose as a REST service that responds in JSON format (to be used by a Ruby on Rails project).

I have only notions about Java web servers / web frameworks. What would be:

a. a suitable Java MVC and

b. a java server

to ease my deployment? I am interested in:

  • easy to build(wrap) the solution
  • easy to maintain / configure the server
  • stable (not experimental)

We use CXF extensively. It is very simple standard JAX-RS annotation based. There is a good tutorial to set it up quickly. It works with or without Spring, but easier with spring, this is my preference. The other option would be Spring REST it is very similar to Spring MVC which is very easy if you know spring already, but on the other hand it is not JAX-RS based.

you might want to give Grails a try - it:

  • shares some similarities with RoR
  • comes bundled with an application server so it's very easy to get up and running
  • allows very simple deployment to a Java application server (eg Tomcat, Jetty)
  • has built-in support for JSON
  • has recent stable releases
  • is under active development

For the server part of the problem, build your code so that it is a servlet and then deploy in a container like Tomcat or Jetty. (There are many others too, but Tomcat and Jetty work very well and are pretty easy to use.)

For the framework, I'd recommend CXF (I've had good success with it in my project) as it keeps the amount of configuration you need to write small (typically just add annotations to mark which methods are to be exposed; the annotations are standardized as JAX-RS ), but many others are valid choices too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM