spring bean 配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd "> <bean id="car1" class="com.smart.Car"> <property name="brand"> <value><![CDATA[<font color="red">奥迪A6</font>]]></value> </property> <property name="color"> <value>红色</value> </property> <property name="maxSpeed"> <value>230</value> </property> </bean> <bean id="car2" class="com.smart.Car"> <property name="brand" value="吉利" /> <property name="color" value="蓝色" /> <property name="maxSpeed" value="200" /> </bean> <bean id="car3" class="com.smart.Car" p:brand="红旗CA72" p:color="黑色" p:maxSpeed="200" /> <bean id="car4" class="com.smart.Car"> <constructor-arg index="0" type="java.lang.String" value="奥迪A6" /> <constructor-arg index="1" type="java.lang.String" value="白色" /> <constructor-arg index="2" type="int" value="250" /> </bean> <bean id="boss1" class="com.smart.Boss"> <constructor-arg index="0" value="John" /> <constructor-arg index="1" ref="car1" /> </bean> <bean id="boss2" class="com.smart.Boss"> <property name="name" value="Jack" /> <property name="car" ref="car1" /> </bean> </beans>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步