在我的控制器中,我有一个如下所示的方法:
@Autowired
StatisticsService statisticsService;
@GetMapping("statistic")
public final WebResponse<List<TierCpStatisticsDataDTO>> getStatisticsInfo(String var) {statisticsService.methodA(); ... ...)
Run Code Online (Sandbox Code Playgroud)
对于“最终”,statisticsService 为 null。当我删除“final”时,statisticsService 会获得正确的实例。
有人能解释为什么会发生这种情况吗?
有线的是,当 Final 存在时,控制器将被代理,如下所示:
但是当我删除final后,控制器就不再被代理了。
我正在尝试使用 spring data elastisearch 保存一些数据。我需要为不同的客户端创建相同的索引。前任。如果我有索引my-index,我需要为客户端A和B创建my-index-A、my-index-B。但是注释@Document仅适用于静态indexName或非线程安全的spEL。
我的问题是,如果我手动创建索引和搜索(ElasticsearchTemplate.createIndex()、NativeSearchQueryBuilder().withIndices()),并删除实体类上的这一行。
@Document(indexName = "my-index-A")
Run Code Online (Sandbox Code Playgroud)
该实体仍然可以收到它的值吗?换句话说,注释
@Id
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String aid;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String userId;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String entityId;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String userName;
Run Code Online (Sandbox Code Playgroud)
还有效吗?