In Minecraft 1.19, you can trade all sorts of items with villagers that live peacefully in villages. These mobs can get several jobs in order to trade different items related to that profession. One of the best among them is a librarian villager, who can trade every enchantment in the form of enchanted books.
Experienced players usually use librarians to obtain enchantments rather than using enchantment tables as it allows them to get specific powerups instead of random ones. Though librarian villagers give an enchanted book on their first trade tier, it might not be Mending. Hence, if you want such rare books from the said entities, you can use this trick.
Steps to get make a villager give Mending enchantment in Minecraft 1.19
1) Find a village with or without a librarian
First, you need to find a village, since it is the only place where regular villagers spawn and live. In it, there can be several employed and unemployed entities. It does not matter whether they are a librarian or not, since you can simply employ a regular villager.
2) Craft or find a lectern in the village to employ a librarian
Next, you must craft a lectern or find one in the village. These are blocks on which you can keep books open, but they are mainly used to employ any villager as a librarian.
You can craft a lectern with four wood slabs and one bookshelf. The moment you place it near an unemployed villager, they will immediately connect with it and become a librarian. After the process is complete, you can interact with the mob to check their trade list.
3) Break the lectern and place it again to shuffle trade list
There is a high chance that you might not get the Mending enchanted book in the first attempt. Though many players will simply leave and create a new librarian to get a different trade list, you can also break the first lectern and place it again.
This will essentially re-employ the librarians and shuffle their trade list. Hence, they will show another enchantment on their list. Using this method, you can keep breaking and placing the block until you get the librarian who trades the rare treasure enchantment.
Of course, this method can be used to get any other type of enchantment as well. Many experienced players use it to create a librarian trading center from which they can obtain every variant available in the game. This trick is mostly used to obtain Mending simply because it is a treasure enchantment and can remove the limited durability of every gear.