In this study, the bound state solutions of the Dirac equation (DE) have been determined with the generalized Cornell potential model (GCPM) under the condition of spin symmetry. The GCPM includes the Cornell potential plus a combination of the harmonic and inversely quadratic potentials. In the framework of the Nikiforov–Uvarov (NU) method, the relativistic and nonrelativistic energy eigenvalues for the GCPM have been obtained. The energies spectra of the Kratzer potential (KP) and the modified Kratzer potential (MKP) have been derived as particular cases of the GCPM. The present results have been applied to some diatomic molecules (DMs) as well as heavy and heavy-light mesons. The energy eigenvalues of the KP and MKP have been computed for several DMs, and they are fully consistent with the results found in the literature. In addition, the energy eigenvalues of the GCPM have been employed for predicting the spin-averaged mass spectra of heavy and heavy-light mesons. One can note that our predictions are in close agreement with the experimental data as well as enhanced compared to the recent studies.