我的会话范围bean:
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
@Component
public class AuthNodes {
private String authNodes;
public String getAuthNodes() {
return authNodes;
}
public void setAuthNodes(String authNodes) {
this.authNodes = authNodes;
}
}
注入到JHipster生成的微服务的REST控制器中:
@RestController
@RequestMapping("/api")
public class NodeResource {
@Autowired
private AuthNodes authNodes;
...
@GetMapping("/nodes-and-children/{user:.+}")
@Timed
public ResponseEntity<List<Node>> getFilteredNodesAndChildren(@PathVariable String user,
@ApiParam Pageable pageable) {
...
String hosts = authNodes.getAuthNodes();
if (hosts == null) {
authNodes.setAuthNodes("my user's authorized node names");
}
...
但是在每次调用时,先前设置的值都会丢失,authNodes.getAuthNodes()将返回null。
有什么问题?
谢谢,Mic