a friend of mine had the same problem with hiring junior developers. by the time they had enough experience so that he could make a profit from their work, they left for higher paying jobs. he barely broke even most of the time so he ended up closing his business because it wasn't viable.
it's also an issue of perception. my company once tried to attract juniors with a high salary (at least 50% higher than local average) but that meant that we couldn't give them a raise early enough. after a year they got a better offer and left.
A key question is whether the training is actually worth what’s being charged for it.
The same issue comes up any time a company makes an "investment" in their staff. The bigger the investment, the bigger the incentive to jump ship.
but they don't stay longer. and unfortunately a pleasant work environment doesn't help because juniors don't know yet that other companies are different. it takes working for a few companies before someone learns to value work culture over a higher salary.
finding the right balance is not easy.