java微服务框架有哪些_java中有哪些常见微服务框架

常见微服务框架介绍:

Spring Boot:这可能是最好的Java微服务框架了,它适用于控制反转、面向切面编程等等。

示例代码:import org.springframework.boot.*;

import org.springframework.boot.autoconfigure.*;

import org.springframework.stereotype.*;

import org.springframework.web.bind.annotation.*;

@RestController

@EnableAutoConfiguration

public class Example {

@RequestMapping("/")

String home() {

return "Hello World!";

}

public static void main(String[] args) throws Exception {

SpringApplication.run(Example.class, args);

}

}

Jersey:这个开源框架支持Java的JAX-RS API,使用起来非常容易。

示例代码:package org.glassfish.jersey.examples.helloworld;

import javax.ws.rs.GET;

import javax.ws.rs.Path;

import javax.ws.rs.Produces;

@Path("helloworld")

public class HelloWorldResource {

public static final String CLICHED_MESSAGE = "Hello World!";

@GET

@Produces("text/plain")

public String getHello() {

return CLICHED_MESSAGE;

}

}

Play:框架可以让你很方便地使用Scala和Java来构建、创建和部署Web应用程序。对于需要并行处理远程调用的RESTful应用程序来说,Play框架是理想的选择。它是模块化的,支持异步。

示例代码:package controllers;

import play.mvc.*;

public class Application extends Controller {

public static void index() {

render();

}

public static void sayHello(String myName) {

render(myName);

}

}

常见微服务框架介绍: Spring Boot:这可能是最好的Java微服务框架了,它适用于控制反转、面向切面编程等等。 示例代码:import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; import org.springframework.stereotype.*; import org.springframework.web.bind.annotation.*; @RestController @EnableAutoConfiguration public class Example { @RequestMapping("/") String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(Example.class, args); } } Jersey:这个开源框架支持Java的JAX-RS API,使用起来非常容易。 示例代码:package org.glassfish.jersey.examples.helloworld; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("helloworld") public class HelloWorldResource { public static final String CLICHED_MESSAGE = "Hello World!"; @GET @Produces("text/plain") public String getHello() { return CLICHED_MESSAGE; } } Play:框架可以让你很方便地使用Scala和Java来构建、创建和部署Web应用程序。对于需要并行处理远程调用的RESTful应用程序来说,Play框架是理想的选择。它是模块化的,支持异步。 示例代码:package controllers; import play.mvc.*; public class Application extends Controller { public static void index() { render(); } public static void sayHello(String myName) { render(myName); } }
经验分享 程序员 微信小程序 职场和发展