关于spring 注解注入的问题
actionContext.xml:<context:annotation-config/><context:component-scanbase-package="cn...
actionContext.xml:
<context:annotation-config />
<context:component-scan base-package="cn.com.sad" />
<bean id="userInfoAction" class="cn.com.sad.web.action.UserInfoAction"
scope="prototype">
<property name="userInfoService" ref="userInfoService" />
</bean>
service(UserInfoService):
@Service
public class UserInfoService {
public void toWrite() {
System.out.println("------service");
}
}
UserInfoAction:
public class UserInfoAction extends ActionSupport {
private static final long serialVersionUID = 1L;
@Autowired
private UserService userInfoService = null;
public String login() {
System.out.println("login!");
userInfoService.toWrite();
return "login";
}
}
请问为什么还注入不了呢 希望有哪位大侠帮帮,实在每分了 真不好意思 在线等。。。 展开
<context:annotation-config />
<context:component-scan base-package="cn.com.sad" />
<bean id="userInfoAction" class="cn.com.sad.web.action.UserInfoAction"
scope="prototype">
<property name="userInfoService" ref="userInfoService" />
</bean>
service(UserInfoService):
@Service
public class UserInfoService {
public void toWrite() {
System.out.println("------service");
}
}
UserInfoAction:
public class UserInfoAction extends ActionSupport {
private static final long serialVersionUID = 1L;
@Autowired
private UserService userInfoService = null;
public String login() {
System.out.println("login!");
userInfoService.toWrite();
return "login";
}
}
请问为什么还注入不了呢 希望有哪位大侠帮帮,实在每分了 真不好意思 在线等。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询