Mending is an enchantment that cannot be crafted and must be bought or obtained (usually from treasure chests). When you gain experience, it will repair items enchanted with Mending as well.