I remember in the 80s and early 90s it was common for a salaried worker to stay at the same company for decades. Since the 2000s, it appears to be less prevalent.
The solution would appear to be to make conditions good and wages competitive for the newly-trained junior workers to improve retention. However, some industries risk their competitiveness with labor costs above a certain level. I wonder how much of the shortage is due to the intransigence of capital versus true limits for competitive pay. I suspect the former for almost all specialized positions experiencing shortfalls, such as pilots, machinists, CNC operators, and millwrights. For unskilled labor I suspect that the wages cannot climb much higher without harming profits or risking competition from overseas.