value="/WEB-INF/tiles-defs.xml" /> <set-property property="moduleAware" value="true" /> </plug-in> ========================= Validator plugin ================================= <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> </plug-in>--> </struts-config>3) crie o arquivo action-servlet.xmlXml<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"><beans> <bean name="/CreateContato" class="com.myapp.action.CreateContatoAction"> <property name="contatoService"></property> </bean> <bean name="/RedirectContato" class="com.myapp.action.RedirectContatoAction"> <property name="contatoService"></property> </bean> <bean id="contatoService" class="com.myapp.service.ContatoServiceImpl"> <!--<property name="contatoDao"> isso causa um erro o correto esta abaixo--> <property name="dao"> <!-- injecao da dependencia--> <bean id="contatoDao" class="com.myapp.dao.ContatoDaoImpl"> </bean> </property> </bean></beans>4) salve os arquivos modificados.5) teste o programa e veja o Log do NB:Nao deve conter nenhum erro, se tiver verifique as configuracoes nos arquivos XMLSep 27, 2012 1:02:18 PM org.springframework.web.struts.ContextLoaderPlugIn initINFO: ContextLoaderPlugIn for Struts ActionServlet 'action, module '': initialization startedSep 27, 2012 1:02:18 PM org.springframework.context.support.AbstractApplicationContext prepareRefreshINFO: Refreshing WebApplicationContext for namespace 'action-servlet': startup date [Thu Sep 27 13:02:18 BRT 2012]; root of context hierarchySep 27, 2012 1:02:19 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitionsINFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/action-servlet.xml]Sep 27, 2012 1:02:20 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletonsINFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@fe2254a: defining beans [/CreateContato,/RedirectContato]; root of factory hierarchySep 27, 2012 1:02:21 PM org.springframework.web.struts.ContextLoaderPlugIn initWebApplicationContextINFO: Using context class 'org.springframework.web.context.support.XmlWebApplicationContext' for servlet 'action'Sep 27, 2012 1:02:21 PM org.springframework.web.struts.ContextLoaderPlugIn initINFO: ContextLoaderPlugIn for Struts ActionServlet 'action', module '': initialization completed in 2610 msSep 27, 2012 1:02:21 PM org.apache.catalina.util.LifecycleBase startINFO: The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SpringLesson08-SpringStruts]] after start() had already been called. The second call will be ignored.6) altere as actions no package actionsCODEpackage com.myapp.action;import com.myapp.model.Contato;import com.myapp.service.ContatoService;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.commons.beanutils.BeanUtils;import org.apache.struts.action.Action;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;public class CreateContatoAction extends Action {// private ContatoService userService = new ContatoServiceImpl(); // com o Spring private ContatoService contatoService; public void setContatoService(ContatoService userService) { this.contatoService = userService; } @Override public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {// return super.execute(mapping, form, request, response); ContatoForm contatoForm = (ContatoForm) form; Contato contato = new Contato(); BeanUtils.copyProperties(contato, contatoForm); contatoService.create(contato); return mapping.findForward("list"); }}CODEpackage com.myapp.action;import com.myapp.service.ContatoService;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;public class RedirectContatoAction extends Action {// private ContatoService contatoService = new ContatoServiceImpl(); // com o Spring private ContatoService contatoService ; public void setContatoService(ContatoService contatoService) { this.contatoService = contatoService; } @Override public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {// return super.execute(mapping, form, request, response); request.setAttribute("contatos", contatoService.findAll()); return mapping.findForward("sucess"); }}7) altere a classe dao.ContatoServiceImplCODEpackage com.myapp.service;import com.myapp.dao.ContatoDao;import com.myapp.model.Contato;import java.util.List;public class ContatoServiceImpl implements ContatoService {// private ContatoDao dao = new ContatoDaoImpl(); // depois do spring private ContatoDao dao; @Override public void create(Contato contato) { getDao().create(contato); } @Override public List<Contato> findAll() { return getDao().findAll(); }}8) compile e teste. veja o erro :LogOffending resource: ServletContext resource [/WEB-INF/action-servlet.xml]Bean '/CreateContato'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: <property> element for property 'contatoService' must specify a ref or valueOffending resource: ServletContext resource [/WEB-INF/action-servlet.xml]Bean '/CreateContato' -> Property 'contatoService' at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)9) acerte o arquivo action-servlet.xml e adicione as ref<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"><beans> <bean name="/CreateContato" class="com.myapp.action.CreateContatoAction"> <property name="contatoService" ref="contatoService"></property> </bean> <bean name="/RedirectContato" class="com.myapp.action.RedirectContatoAction"> <property name="contatoService" ref="contatoService"></property> </bean> <bean id="contatoService" class="com.myapp.service.ContatoServiceImpl"> <!--<property name="contatoDao"> isso causa um erro o correto esta abaixo--> <property name="dao"> <!-- injecao da dependencia--> <bean id="contatoDao" class="com.myapp.dao.ContatoDaoImpl"> </bean> </property> </bean></beans>10) compile e teste. veja o erro : Logorg.springframework.beans.factory.BeanCreationException: Error creating bean with name '/CreateContato'