Preheat oven to 350°. Grease a 13" x 9" baking dish with cooking spray. In a large pot of boiling salted water, cook spaghetti, stirring occasionally, until al dente according to package directions. Drain and set aside.
Meanwhile, in a large skillet over medium heat, heat oil. Add onions and cook, stirring occasionally, until softened and translucent, about 7 minutes. Add garlic and cook, stirring, until fragrant, about 1 minute more. Add beef and Italian seasoning; season with salt and pepper. Cook, breaking up meat with a wooden spoon, until no longer pink, about 8 minutes.
Pour in crushed tomatoes, tomato sauce, and basil. Bring to a simmer and cook, stirring occasionally, until slightly reduced, about 10 minutes; season with salt and pepper.
Add pasta, toss to combine, and transfer to prepared dish. Top with mozzarella and Parmesan.
Bake until cheese is melted and pasta is warmed through, about 20 minutes.
Top with parsley.
