A bacillus subtilis HJDA32 strain is preserved on September 25, 2012 with the preservation number of CGMCC (China General Microbiological Culture Collection Center) No.6624, which is separated from solid fermentative substrate of vinegar in the Shanxi province Qingxu mature vinegar plant. The strains are cultured in a beef extract peptone basic medium and arranged in pole, single, paired or chained shape with the size between 0.6-0.85mu m*1.5-3.5mu m, and have capsules; elliptical spores are cultured on a raw spore culture medium; the strain is identified to be bacillus subtilis through catalase and carbon source utilization test, gelatin hydrolysis, starch hydrolysis, ethanol oxidation, acetic acid oxidation and other physiological and biochemical identifications and 16SrDNA (deoxyribonucleic acid) phylogenetic analysis; and the bacillus subtilis HJDA32 strain is used as a production strain, cultured with fermenting culture fluid, and subjected to centrifuge, ammonium sulfate powder salting out and centrifuge to obtain the bacteriocin. The bacteriocin is wide in antimicrobial spectrum and high in bacteriostatic activity, can inhibit various food-borne pathogenic bacteria, as well as gram positive and gram negative bacteria causing food spoilage, and can be used in food preservatives.