|
15 | 15 | import org.slf4j.LoggerFactory; |
16 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
17 | 17 | import org.springframework.beans.factory.annotation.Value; |
| 18 | +import org.springframework.context.annotation.Lazy; |
18 | 19 | import org.springframework.context.annotation.Profile; |
19 | 20 | import org.springframework.data.elasticsearch.core.document.Document; |
20 | 21 | import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; |
@@ -58,16 +59,18 @@ public class IndexServiceImpl implements IndexService { |
58 | 59 | private final ClassificationSeriesRepository classificationRepository; |
59 | 60 | private final OpenSearchRestTemplate elasticsearchOperations; |
60 | 61 | private final DocumentMapper documentMapper; |
61 | | - private final IndexService self; |
| 62 | + |
| 63 | + @Autowired |
| 64 | + @Lazy |
| 65 | + private IndexService indexService; |
62 | 66 |
|
63 | 67 | @Autowired |
64 | 68 | public IndexServiceImpl( |
65 | 69 | ClassificationSeriesRepository classificationRepository, |
66 | | - OpenSearchRestTemplate elasticsearchOperations,IndexService self) { |
| 70 | + OpenSearchRestTemplate elasticsearchOperations) { |
67 | 71 | this.classificationRepository = classificationRepository; |
68 | 72 | this.elasticsearchOperations = elasticsearchOperations; |
69 | 73 | this.documentMapper = new DocumentMapper(); |
70 | | - this.self = self; |
71 | 74 | } |
72 | 75 |
|
73 | 76 | private IndexCoordinates getIndexCoordinates() { |
@@ -162,7 +165,7 @@ public void indexAsync(Long classificationSeriesId) { |
162 | 165 | try { |
163 | 166 | ClassificationSeries classification = |
164 | 167 | classificationRepository.getOne(classificationSeriesId); |
165 | | - self.indexSync(classification); |
| 168 | + indexService.indexSync(classification); |
166 | 169 | } catch (Exception e) { |
167 | 170 | log.warn( |
168 | 171 | "Failed to index classification {}: {}", |
|
0 commit comments