A mass spring system has a natural frequency that can be calculated , T = m/k square root multiply by 2 pi. Let this frequency be 5 Hz. To produce resonance a motor can be attached to the support at the top of the spring . The motor frequency must be close to 5 Hz to cause the mass to oscillate at maximum amplitude.
Other ways to produce this resonance effect require some imagination.
1. Blow gust of wind at a frequency of 5 Hz up or down the spring
2. If the mass is a magnet , place a coil with alternating current of 5 HZ below the magnet
Resonance requires a periodic force on the system that matches the natural frequency of the system.