我正在尝试Single.just(..)
从我的端点返回一个。我使用 jersey 和 rx-jersey 创建了它。我在浏览器上不断收到此消息:
No serializer found for class io.reactivex.internal.operators.single.SingleJust and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
这是我的代码:-
泽西配置:
@Component
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(RxJerseyServerFeature.class);
register(RxJerseyClientFeature.class);
register(new JacksonJsonProvider(new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)));
register(UserService.class);
}
}
我的终点
@Path("/users")
public class UserService {
@GET
@Path("/setup/rx")
@Produces(MediaType.APPLICATION_JSON)
public Single<User> setupRx() {
return Single.just(new User(29));
}
}
用户:-
public class User {
private Integer age;
//getters and settters