Why the injection dependency of spring construction is immutable?

spring framework, why can dependency immutability be guaranteed by constructor injection?

Dec.08,2021

if I am not good at Chinese, I can't understand what dependence is immutable. It is your ability to make complicated things simple. It is a hoax to say that simple things are complex-this is common in the Chinese version of technical books.

back to your question, if it is constructor injection, you can only pass in the object when you create an instance, and there is no way to modify it after instance creation, while setter injection can call setter modification again. For example, after
constructor is injected into, new Zoo (monkey), monkey cannot be changed:
class Zoo {

public Zoo(Animal animal) {
}

}

After

setter is injected into, setAnimal (monkey), you can modify it by calling setAnimal (panda):
class Zoo {

public void setAnimal(Animal animal) {
}

}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37713-2c087.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37713-2c087.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?