The $unionWith operator has been supported by UnionWithOperation since Spring Data MongoDB 3.1 but is not currently documented in the list of Spring Data's Supported Aggregation Operators.
In "Table 12. Aggregation Operations currently supported by Spring Data MongoDB", unionWith should be included in the list of Pipeline Aggregation Operators.