  The formation process of massive stars is still poorly understood. Massive
young stellar objects (mYSOs) are deeply embedded in their parental clouds,
they are rare and thus typically distant, and their reddened spectra usually
preclude the determination of their photospheric parameters. M17 is one of the
best studied HII regions in the sky, is relatively nearby, and hosts a young
stellar population. With X-shooter on the ESO Very Large Telescope we have
obtained optical to near-infrared spectra of candidate mYSOs, identified by
Hanson et al. (1997), and a few OB stars in this region. The large wavelength
coverage enables a detailed spectroscopic analysis of their photospheres and
circumstellar disks. We confirm the pre-main sequence (PMS) nature of six of
the stars and characterise the O stars. The PMS stars have radii consistent
with being contracting towards the main sequence and are surrounded by a
remnant accretion disk. The observed infrared excess and the (double-peaked)
emission lines provide the opportunity to measure structured velocity profiles
in the disks. We compare the observed properties of this unique sample of young
massive stars with evolutionary tracks of massive protostars by Hosokawa &
Omukai (2009), and propose that these mYSOs near the western edge of the HII
region are on their way to become main-sequence stars ($\sim 6 - 20$
$M_{\odot}$) after having undergone high mass-accretion rates (${\dot{M}_{\rm
acc}} \sim 10^{-4} - 10^{-3}$ $M_{\odot}$ $\rm yr^{-1}$). Their spin
distribution upon arrival at the zero age main sequence (ZAMS) is consistent
with that observed for young B stars, assuming conservation of angular momentum
and homologous contraction.
