Three options:
1) Traps. Lots of spikes and/or discs. Stone fall traps don't do enough damage, but weapon traps still work fine.
2) Seal off the outside world completely. Always works, never fails. You can use an airlock system of bridges to let traders in.
3) Military dwarves.
The best way I've found to get the military working is to do this, in this order:
1) Build a weapon rack. Place it in a room, designate it to be a room.
2) Go to the military screen and create a new uniform. Set it up how you want and name it something you can remember.
3) Create a squad of dorfs. Preferably expendable dorfs.
4) When you create the squad it will ask you for a uniform, select the uniform you made in step 2.
5) Designate a burrow encompassing the entire surface. Call this burrow "surface" or something similar.
6) Go to scheduling.
7) Create alternating schedule that change each month. Rotate between defend burrow (surface) and no orders. Leave all 10 dorfs required for this.
Go back to the weapon rack that is your barracks, highlight your new squad and push T, they will now go here for individual training during their off months.
What these steps have done is to make your dwarves equip all of their gear, assuming it is available and your arsenal dwarf is not on break. During even months the dwarves will scour the outside world, attacking any hostiles spotted. During odd months they will do individual training, as well as eat/sleep/drink so they will not starve to death.
To ensure full coverage, create two squads. Have the schedules offset so that at any given time, 1 squad is defending the burrow while the other has no orders, which means they will do individual training.
This will give you 10 dwarves on patrol and 10 dwarves eating/sleeping/boozing/training at any given time. Go ahead and assign everyone plate armor, shields, and swords or axes from the very start, even if you don't have it available right now. Your arsenal dwarf will assign the gear to them as it becomes available.
Don't skimp on the armor though! Armor is
EXTREMELY important. In the previous version it was all about dodging and shield skills, now its all about armor.
To detect an ambush so that your military dwarves will rush over there to start chopping things, just chain up a single animal at your entrance, so the ambush will be uncloaked by the sacrificial animal.
Alternatively, you can use a punishment burrow.
Make food stockpile and well at your entrance room. Make it a burrow. Assign dwarves you don't like to that burrow, so they will eat/drink/sleep/die in that burrow. Bonus points if that dwarf is a noble.