Setando senha do JPA pelo Spring (Spring-Annotation)

0 respostas
zimmermarques

Pessoal, não quero deixar o usuário e senha para conectar no banco dentro do xml do spring ou do persistence.xml, quero colocar dentro de uma classe e pegar dentro do xml do spring. stou fazendo assim mas não roda

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:aop="http://www.springframework.org/schema/aop" xmlns:sa="http://sannotations.sourceforge.net/context" xmlns:jee="http://www.springframework.org/schema/jee"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
       http://sannotations.sourceforge.net/context http://sannotations.sourceforge.net/context.xsd"
        default-autowire="byName" default-lazy-init="false">
        <sa:annotation-autoload jarMarkerFile="to.properties" scanDirs="true"/>
        
        <tx:annotation-driven transaction-manager="myTxManager"/>
        
		<bean id="myTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
			<property name="entityManagerFactory" ref="entityManagerFactory"></property>
        </bean>

        <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
			<property name="persistenceUnitName" value="sisport"></property>
			<property name="jpaProperties">
     		</property>
        </bean>
        
        <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"></bean>
        <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"></bean>
        
</beans>

minha classe faz isso:

package util;

import java.util.Properties;
import net.sourceforge.sannotations.annotation.Bean;

@SuppressWarnings("unchecked")
@Bean(name="util")
public class JpaUtil {

	public Properties conf() {
		
		Properties p = new Properties();
			
		p.put("hibernate.connection.username", "root");
		p.put("hibernate.connection.password", "123456");
		p.put("hibernate.hbm2ddl.auto", "update");
		
		return p;
	}	
	
}

se alguém puder me ajudar fico grato.

Criado 8 de abril de 2008
Respostas 0
Participantes 1