spring 中同步方法的注解
Annotation for synchronize a method in spring
我有一个简单的休息 api 在我的休息控制器中,
@RequestMapping(value = "/myservice", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_USER')")
public HttpEntity<String> myService() {
//do something
}
Rest Controller 默认是单例的,方法不是线程安全的(非同步的)。是否在线程安全(同步)的方法级别定义了注解?
能不能只用synchronized关键字?
@RequestMapping(value = "/myservice", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_USER')")
public synchronized HttpEntity<String> myService() {
//do something
}
我有一个简单的休息 api 在我的休息控制器中,
@RequestMapping(value = "/myservice", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_USER')")
public HttpEntity<String> myService() {
//do something
}
Rest Controller 默认是单例的,方法不是线程安全的(非同步的)。是否在线程安全(同步)的方法级别定义了注解?
能不能只用synchronized关键字?
@RequestMapping(value = "/myservice", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_USER')")
public synchronized HttpEntity<String> myService() {
//do something
}