我正在使用Spring 4.1.4并实现一项简单的REST服务.我有一个POST方法来获取一个Person对象作为请求.
@ResponseStatus(value = HttpStatus.CREATED)
@RequestMapping(value = "", method = RequestMethod.POST, headers = "Accept=application/json", consumes = "application/json")
public void add(@Valid @RequestBody Person oPerson) throws Exception {
//do the things
}
Run Code Online (Sandbox Code Playgroud)
豆:
public class Person {
public Person(){ }
private String firstname;
private String lastname;
private Integer activeState;
//getter+setter
}
Run Code Online (Sandbox Code Playgroud)
我的问题是 - 是否有可能为bean中的属性设置默认值.像这样的东西:
@Value(default=7)
private Integer activeState;
Run Code Online (Sandbox Code Playgroud)
我知道在方法中使用@RequestParam注释时@RestController可以设置默认值@RequestParam(value="activeState", required=false, defaultValue="2")但是有可能在类级别上做类似的事情吗?
我正在使用spring-data-cassandra(1.3.1.RELEASE)连接到cassandra数据库。有没有办法改变spring-data-cassandra中的一致性级别。默认情况下为1 级(spring-data-cassandra中的默认一致性级别是多少?)。但是如何改变呢?
谢谢!