i'm having error while trying dependency injection spring framework
invalid property 'messageservice ' of bean class [person]: bean property 'messageservice ' not writable or has invalid setter method. did mean 'messageservice'?
here's class person:
public class person { private messageservice messageservice; public void setmessageservice(messageservice messageservice){ this.messageservice = messageservice; } public messageservice getmessageservice() { return this.messageservice; } public void chao(string subject, string message) { messageservice.sendmessage(subject,message); } }
here's beans.xml
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" 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.xsd"> <bean id="email" class="email"></bean> <bean id="person" class="person"> <property name="messageservice " ref="email"></property> </bean> </beans>
and main class
public class main { public static void main(string args[]) throws exception{ applicationcontext context = new classpathxmlapplicationcontext("beans.xml"); person test = (person) context.getbean("person"); test.chao("abc","abc"); } }
messageservice
interface, class email implements messageservice
can tells me i'm doing wrong? thank much
there blank @ end of name="messageservice "
. please remove it.
Comments
Post a Comment