
<bean id="helloWorld" class="com.gzk.HelloWorld" scope="singleton" > <property name="message" value="Hello World!"/> </bean> <bean class="com.gzk.InitHelloWorld" /> <!--这句话不加</bean> 也是一个 initHelloWorld 类的对象的意思吗?--> 1 gzk329 OP 是不是要加别的参数的时候用一对标签? 不然的话就可以省略? 如果是这样的化那是我傻了 |
2 gzk329 OP 但是这句话连 id 都能省掉了嘛 |
3 lxk11153 2020 年 8 月 25 日 1. 可以省略,如果没子标签 2. 属性能否省略你得看实现呀,spring-bean 的 id 实现是有默认 id 生成策略的,默认是类名+序号吧 |
4 stevenkang 2020 年 8 月 25 日 找到一点资料: https://www.w3.org/standards/xml/core.html All elements must be closed or marked as empty. Empty elements can be closed as normal, <happiness></happiness> or you can use a special short-form, <happiness /> instead. |