Injeção de dependências Spring com Annotations

0 respostas
D

Bom dia, estou tentando fazer injeção de dependências, porém sem sucesso, segue o Xml e a injeção em seguida:

<?xml  version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns:aop="http://www.springframework.org/schema/aop"  
    xmlns:context="http://www.springframework.org/schema/context"  
    xmlns:jee="http://www.springframework.org/schema/jee"  
    xmlns:lang="http://www.springframework.org/schema/lang"  
    xmlns:p="http://www.springframework.org/schema/p"  
    xmlns:tx="http://www.springframework.org/schema/tx"  
    xmlns:util="http://www.springframework.org/schema/util"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd  
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd  
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd  
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd  
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd  
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd  
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">  
      
    <context:component-scan base-package="."/>  
    <context:annotation-config/>   
    <tx:annotation-driven/>  
      
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
        <property name="driverClassName" value="org.postgresql.Driver" />  
        <property name="url" value="jdbc:postgresql://127.0.0.1/yttria" />  
        <property name="username" value="postgres" />  
        <property name="password" value="projetos" />  
    </bean>  
  
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
        <property name="annotatedClasses">  
            <list>  
                <value>model.Prova</value>  
                <value>model.Usuario</value>  
                <value>model.Telefone</value>  
                <value>model.Questao</value>  
                <value>model.ProvaRealizada</value>  
                <value>model.Pessoa</value>  
                <value>model.Pais</value>  
                <value>model.Materia</value>  
                <value>model.Estado</value>  
                <value>model.Endereco</value>  
                <value>model.Alternativa</value>  
            </list>  
        </property>  
          
        <property name="hibernateProperties">  
            <props>  
                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>  
                <prop key="hibernate.show_sql">true</prop>  
                <prop key="hibernate.format_sql">true</prop>  
            </props>  
        </property>  
    </bean>  
  
</beans>

E a injeção da dependência via Annotation:

view plaincopy to clipboardprint?

private UsuarioService uService;  
  
@Autowired  
public void setUsuarioService(UsuarioService uService){  
    this.uService = uService;  
}

A Classe UsuarioService está Anotada como @Service

Criado 29 de agosto de 2012
Respostas 0
Participantes 1