Gentle handling to build trust, proper environment/conditions (tank size, hides, temps, humidity, etc), and proper food size and frequency should equate to a happy BP.
If it's only cage defensiveness, or a food response, and all other boxes are checked, try hook training. Feel free to ask if you are not sure what that is or how to do it.
Snakes can learn association, but not like a dog or cat. They can be conditioned, but not really trained. They do not aim to please and are not that sophisticated. Spraying the snake with a water bottle to stop bad behavior will not work and the snake will only associate you with getting sprayed, not undesired behavior.