[英]How do I know what implementation of jaxrs I am using?
I have a Java 1.7 starts application.我有一个 Java 1.7 启动应用程序。 It does have some RESTful api's.
它确实有一些 RESTful api。
I would like to add @JsonIgnore
to a filed so that it is not returned in the api.我想将
@JsonIgnore
添加到归档中,以便它不会在 api 中返回。
Eg例如
import com.fasterxml.jackson.annotation.JsonIgnore;
private java.lang.String username;
@JsonIgnore
private java.lang.String password;
Does not ignore the password.不忽略密码。
"member": {
"password": "**************",
"username": "richard"
}
I think the reason why @JsonIgnore
does not work, is because I use com.fasterxml.jackson.annotation.JsonIgnore
.我认为
@JsonIgnore
不起作用的原因是因为我使用com.fasterxml.jackson.annotation.JsonIgnore
。 Should I use a different annotation from a different library?我应该使用来自不同库的不同注释吗? ie Is my implementation of jaxrs maybe not
com.fasterxml.jackson
?即我的 jaxrs 实现可能不是
com.fasterxml.jackson
吗? How do I tell?我该怎么说?
The IntelliJ classpath has: IntelliJ 类路径具有:
(I have tried net.minidev.json.annotate.JsonIgnore
with no success) (我试过
net.minidev.json.annotate.JsonIgnore
没有成功)
More info:更多信息:
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.3</version>
</dependency>
and和
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.11.2</version>
</dependency>
Is this the problem?这是问题吗? two versions.
两个版本。 I am not sure where the 2.0,5 version comes from.
我不确定 2.0,5 版本来自哪里。 as it is not defined in the pom.
因为它没有在 pom 中定义。
You don't need a @JsonIgnore in this case.在这种情况下,您不需要 @JsonIgnore。 You can simply omit the variable that you don't want deserialized(the password in this case) and jackson will just return you the username.
您可以简单地省略您不想反序列化的变量(在这种情况下为密码),jackson 只会返回您的用户名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.