If starting from scratch, with only requirements of JVM and existing MySQL database of medium complexity, and with the goal of doing only REST, nothing else, what is a good example of components I should use?
Want to keep it as simple as possible.
A few simple options can be:
Spark Framework , Sinatra-inspired + uses nice Java 8 features. Quick start example:
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
}
Spring Boot , a simple way to start in Spring ecosystem. Quick start:
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
Spring has Spring MVC module for building RETSful APIs, here's an example: http://spring.io/guides/gs/rest-service/
You can also take a look at other JVM languages, for example Play Framework in Scala or Grails in Groovy.
UPDATE
I forgot to mention Dropwizard . It uses JAX-RS for RESTful APIs, which can look very verbose, but it's very mature and stable. Here's quick start guide: http://www.dropwizard.io/0.9.2/docs/getting-started.html
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.