The cheap options
- Zombie/skeleton/spider spawner trap — find a dungeon, funnel the mobs into a kill chamber. A few levels per minute with almost no build cost.
- Furnace array with a hopper system — smelting stone or cacti produces steady experience while you do other things.
- Fishing — small but steady XP plus treasure, and it needs no build at all.
The high-yield options
- Gold farm (nether portal + zombie piglins) — very high XP per hour with no spawner needed.
- Enderman farm in the End — the fastest XP in the game once built, though it requires reaching the End.
- Guardian farm at an ocean monument — excellent XP and prismarine by-products.
- Raid farm / pillager outpost — high XP plus emeralds and loot.
Getting experience to the player
Design the kill chamber so the final hit is yours — a one-hit drop (typically a 22-block fall for most hostile mobs) leaves them on half a heart, so one sword swing kills and credits you with the experience. Funnel the orbs with a short drop to the player, and keep Mending gear equipped so the farm repairs it as it runs.