1. 整合RESTEasy和Jackson2
需要引入resteasy-jackson-provider.jar
2.一个简单的Object
package com.example.rest.resteasy.model;
public class Customer {
private int id;
private String firstName;
private String lastName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
3. REST Service
package com.example.rest.resteasy.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import com.example.rest.resteasy.model.Customer;
@Path("/hello")
public class HelloWorldRestService {
@GET
@Path("/customer/json")
@Produces("application/json")
public Customer getProductInJSON() {
Customer customer = new Customer();
customer.setFirstName("first");
customer.setLastName("last");
customer.setId(100);
return customer;
}
}
4. RUN
请求:http://localhost:8080/resteasy-example/hello/customer/json
- 大小: 6.2 KB
分享到:
相关推荐
#resteasy-guice-mybatis resteasy + guice + mybatis + mysql项目演示
Spring整合RestEasy示例工程源码,Spring+Jetty+RestEasy
NULL 博文链接:https://webexpressor.iteye.com/blog/1627389
java运行依赖jar包
resteasy不使用tomcat使用netty实现,实现了高性能,也可以不需要tomcat的容器,一个主函数就能执行
宁静的春天 Resteasy + Spring + Netty示例 作为spring bean注入resteasy提供者/控制器 验证 ==================== 在Main.java中运行 测试
可查询的 Quarkus + Resteasy +HibernatePanache
春假Spring + Resteasy + Maven + JUnit + Mockito + AngularJS + Karma + Jasmine + Wildfly POC 这是一个使用上述技术的 POC。 该项目已使用 Maven 构建,并设置为在 Wildfly 8.x 中运行。 要对其进行测试,请配置...
使用RESTEasy+guice实现上传下载文件
RESTEasy JSON DEMO
案例基于 jboss 7.1.0 和restEasy3.0.18,是目前最新的,因为在网上看到restEasy的例子都比较旧了,所以想到自己写一个案例。直接进入正题。 因为使用的是jboss7,所以restEasy已经集成在里面了,直接用就行,甚至...
离线安装包,亲测可用
NULL 博文链接:https://jerval.iteye.com/blog/2231360
Resteasy + Spring + Netty sample Inject resteasy provider / controllers as spring bean Authentication Run at Main.java Test http://localhost:8082/resteasy/hello/world 教程 jax-rs规范用法: ...
休息的例子 基本的 JBoss ReseEASY 示例项目 基于 Nikos Maravitsas 的教程,JSON Example With RESTEasy + Jackson
RESTEasy + Spring integration example http://localhost:8080/RESTfulExample/customer/print JBoss RESTEasy 是一个用来使用Java语言开发 RESTFul Web服务的框架。
resteasy
开发工具采用IDEA,用maven构建的项目,框架采用SpringMVC,数据库采用mysql与mybatis配合,数据格式采用阿里巴巴工具fastJson,数据源druid,另外还添加了resteasy中的功能
堆栈将Weld 3用于CDI,将RestEasy 3.5用于JAX-RS,将Johnzon 1.1用于JSON 该示例应用程序的总大小约为12mb ,完整的Docker映像仅为55mb ! 注意:已通过JDK 11-ea + 23测试 如何 打包并生成target/modules文件夹...