The Kibble-Zurek scenario for nucleation of topological defects of the orde
r parameter during a symmetry-breaking phase transition in a. superconducti
ng ring is investigated. Solving numerically the set of time-dependent Ginz
burg-Landau (TDGL) equations coupled with the temperature diffusion equatio
n, we predict spontaneous generation of the magnetic flux inside the superc
onducting ring. Josephson weak links in the ring increase the magnitude of
the spontaneously generated magnetic flux.