I came across this issue with Scottie when he was between 7 to 11 months (can't remember exactly). I looked up some training videos and this ended up working for me (the pennies in a can didn't work for him):
Have someone knock on the door, on the wall, make noise outside the door, and various noises that prompts the barking. Each time right after the noise, you feed the pup a treat. Initially stuff the pup with treats right after the noise. Then gradually increase the amount of time he/she's quiet before treating. Before you know it, he/she's been conditioned that those noises are okay and they'll stop barking.
I've also read a 3-bark rule somewhere here on YT, where it's okay to bark 3 times as an alarm to you that someone's at the door. With this though, you'll have to proceed to train the dog "enough" and "quiet". So, each time they're allowed 3 barks, then you give the commands "enough" and "quiet". Difficulty for Scottie was teaching him to "quiet", you have to first teach "speak".
Spray bottle works too. But for me, I use that as a last resort. Think it's better to train them out of the annoying barking first. If he gets too crazy, then I spray. I wouldn't want to risk spraying too often and having him eventually think it's no big deal lol