Why do you use spring boot to write configuration with java? isn't xml good?

in the configuration java, you have to recompile every time you modify it. Isn"t it good to write the configuration file? Why are the configurations in the springboot project written in java, or are there other considerations?

May.13,2021

is flexible. Can I write java in xml? In xml, what do you want to do by determining the environment variable to change the configuration? If directly in java is fine. It is sometimes difficult to find that a class name or variable name is wrong in xml. In java, the compiler reports an error directly. What xml can do, java can do, what java can do, xml is far inferior. Xml makes it easy for people who can't write java to write configurations. If the person who maintains the configuration can java, himself, then xml has no advantage.


groovy DSL means dissatisfied. It not only has the powerful function of java code, but also does not need to be recompiled and executed dynamically. Brother dei, Grails really doesn't know anything about it?


build your own SSH or SSM framework based on XML configuration, and you will know that


"configuration" generally refers to "things that will be different in different environments"
, while xml usually expresses "configuration of bean", such as instantiating which bean, dependencies look like.
so, if the configuration of bean is different in different environments, it may be useful to extract xml (because profile is also available)
. Conversely, if the configuration of bean does not change due to changes in the environment, you do not need to extract the code, just write it into the code, and save the effort of maintaining xml

.
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-1b366e2-2c02d.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-1b366e2-2c02d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?