Advertisement
tadeuespindola

spring-config.xml

Nov 30th, 2019
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.     xmlns:context="http://www.springframework.org/schema/context"
  5.     xmlns:jpa="http://www.springframework.org/schema/data/jpa"
  6.     xsi:schemaLocation="
  7.        http://www.springframework.org/schema/beans
  8.        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  9.        http://www.springframework.org/schema/context
  10.        http://www.springframework.org/schema/context/spring-context-3.0.xsd
  11.        http://www.springframework.org/schema/data/jpa
  12.        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
  13.     default-lazy-init="true">
  14.  
  15.     <!-- Ativa recursos automáticos no Spring como Injeção de Dependecia por anotações -->
  16.     <context:annotation-config />
  17.     <context:component-scan base-package="br.com.uniciv.spingdata.model" />
  18.  
  19.      <!-- Define o DataSource e a conexão com o banco de dados -->
  20.      <bean
  21.      id="dataSource"
  22.      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  23.          <property name="driverClassName" value="org.postgresql.Driver"/>
  24.          <property name="url" value="jdbc:postgresql://localhost:5432/unicivspringdata"/>
  25.          <property name="username" value="postgres"/>
  26.          <property name="password" value="Postgres2018!"/>
  27.      </bean>    
  28.      
  29.      <!-- Define as configurações do JPA -->
  30.      <bean
  31.      id="entityManagerFactory"
  32.      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
  33.      scope="singleton">
  34.           <property name="dataSource" ref="dataSource"/>
  35.           <property name="jpaVendorAdapter">
  36.                 <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
  37.                    <property name="database" value="POSTGRESQL"/>
  38.                    <property name="generateDdl" value="true"/> <!-- Gerar as tabelas no banco -->
  39.                 </bean>
  40.           </property>
  41.           <property name="persistenceUnitName" value="uniciv-springdata"/>
  42.      </bean>
  43.      
  44.      <!-- Ativa o controle transacional -->
  45.      <bean id="transactionManager"
  46.        class="org.springframework.orm.jpa.JpaTransactionManager" scope="singleton">
  47.         <property name="entityManagerFactory" ref="entityManagerFactory" />    
  48.      </bean>
  49.  
  50.      <!-- Ativa os recursos para os Repository -->
  51.     <jpa:repositories base-package="br.com.uniciv.spingdata.repository" />
  52. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement