我正在尝试测试客户端/服务器应用程序,并使用Maven来处理构建/测试/部署.要测试应用程序,我需要:
步骤1,2,4和5将使用maven-exec-plugin.第3步将使用maven-surefire-plugin.
问题是所有这5个步骤都将在"测试"阶段发生.Maven允许以特定顺序执行插件.exec-plugin可以使用多个条目多次运行.问题是我需要在4个exec-plugin执行的中间使用surefire-plugin.
有没有人曾经遇到过这个,或者知道如何构建插件和执行的?
我有许多类要序列化为 JSON。它们非常相似,所以我想知道是否有比每次出现这种模式时创建 3 个非常接近相同的类更好的方法来做到这一点:
public class SomethingFoo {
@JsonProperty("foo")
Identifier foo
// other properties
}
public class SomethingBar {
@JsonProperty("bar")
Identifier bar
// other properties
}
public class SomethingBaz {
@JsonProperty("baz")
Identifier baz
// other properties
}
Run Code Online (Sandbox Code Playgroud)
标识符是一个只包含一个字段的类:
public class Identifier {
@JsonProperty("name")
String name = "";
}
Run Code Online (Sandbox Code Playgroud)
我想做的是将标识符更改为:
public class Identifier {
@JsonProperty("name")
String name = "";
@JsonIgnore
IdentifierType type;
}
public Enum IdentifierType {
FOO, BAR, BAZ;
}
Run Code Online (Sandbox Code Playgroud)
然后我想使用标识符中的“类型”字段来更改包含这些标识符的对象中标识符字段的名称。
然后我想用这个替换SomethingFoo、SomethingBar和SomethingBaz:
public class Something {
@JsonProperty(??????)
Identifier name
// …Run Code Online (Sandbox Code Playgroud)