Unfortunately without switching often, it does not appear that one can maximize their total compensation, simply because companies will often reward new employees more than existing ones.
I'm surprised I see much more emphasize on money and almost nobody mentions working on something less trivial or using interesting technology. The latter could be simply different from what you are bored with by now (e.g. Flink after Spark, Scala after Java, streaming after batch processing). Especially taking into account that in large companies with the best compensation you typically end up in a silo in this respect.