FAQ(8):spring:遺漏編寫bean的無參建構函式
阿新 • • 發佈:2018-12-30
BUG:
Defines a single (usually named) bean. A bean definition may contain nested(巢狀)tags for constructor arguments, property values, lookup methods, and replaced methods. Mixing constructor injection and setter injection on the same bean is explicitly supported.
beans.xml:
<bean id="person" class="com.spring.beans.autowire.Person"> <property name="address" ref="address"></property> <property name="car" ref="car"></property> <property name="name" value="mmb"></property> </bean>
大意:需要寫一個無參構造器!
解決:在person.java加入:
public Person() {
super();
// TODO 自動生成的建構函式存根
}