Advertisement
Guest User

appConfig

a guest
Mar 12th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <beans xmlns="http://www.springframework.org/schema/beans"
  8. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9. xmlns:context="http://www.springframework.org/schema/context"
  10. xmlns:tx="http://www.springframework.org/schema/tx"
  11. xmlns:jpa="http://www.springframework.org/schema/data/jpa"
  12. xsi:schemaLocation="
  13. http://www.springframework.org/schema/beans
  14. http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  15. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
  16. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
  17. http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
  18.  
  19. <jpa:repositories base-package="com.test.repo" /><!--scans the query class and registers for future use-->
  20.  
  21. <bean id="entityManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  22. <property name="dataSource" ref="dataSource" />
  23. <property name="packagesToScan" value="com.test.model" /><!--scans model/entity/domain(name 3 but same) and registers-->
  24. <property name="jpaVendorAdapter">
  25. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
  26. </property>
  27.  
  28. <property name="jpaProperties">
  29. <props>
  30. <prop key="hibernate.hbm2ddl.auto">none</prop><!--automatically creates
  31. db table from entity for first run.there are drop-create and none options too -->
  32. <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop><!--uses this dialect to cantact database-->
  33. <!--prop key="hibernate.hbm2ddl.import_files">populate.sql</prop-->
  34. <!--you can populate table with data if you want some-->
  35. <prop key="hibernate.show_sql">true</prop>
  36. <prop key="hibernate.connection.characterEncoding">UTF-8</prop>
  37. <prop key="hibernate.connection.useUnicode">true</prop>
  38. </props>
  39. </property>
  40. </bean>
  41.  
  42. <bean id="dataSource"
  43. class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  44. <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  45. <property name="url" value="jdbc:mysql://localhost:3306/inventoryMgmt"/>
  46. <property name="username" value="root" />
  47. <property name="password" value="root" />
  48. </bean>
  49.  
  50. <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  51. <property name="entityManagerFactory" ref="entityManager" />
  52. </bean>
  53.  
  54. <!-- Scan for transaction-based resources -->
  55. <context:component-scan base-package="com.test.model" />
  56. <context:component-scan base-package="com.test.controller" />
  57. <context:component-scan base-package="com.test.repo"/>
  58. <context:component-scan base-package="com.test.service"/>
  59. <context:component-scan base-package="com.test.serviceImpl"/>
  60.  
  61. <tx:annotation-driven transaction-manager="transactionManager"/>
  62.  
  63. <bean id="persistenceExceptionTranslationPostProcessor"
  64. class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
  65.  
  66. <bean id="multipartResolver"
  67. class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
  68. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement