Guest User

Untitled

a guest
May 17th, 2017
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns:mvc="http://www.springframework.org/schema/mvc"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  5. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
  6. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  7. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
  8. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
  9.  
  10. <!-- It register the beans in context and scan the annotations inside beans and activate them --><!-- This allow for dispatching requests to Controllers -->
  11. <context:component-scan base-package="com.controller" />
  12.  
  13.  
  14. <mvc:annotation-driven />
  15.  
  16. <!-- This helps in mapping the logical view names to directly view files under a certain pre-configured directory -->
  17. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  18. <property name="prefix" value="/WEB-INF/views/" />
  19. <property name="suffix" value=".jsp" />
  20. </bean>
  21.  
  22. <!-- This resolves messages from resource bundles for different locales -->
  23. <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
  24. <property name="basename" value="messages" />
  25. </bean>
  26.  
  27. <!-- To validate the posted add employee form -->
  28. <bean id="studentValidator" class="com.controller.validator.StudentValidator" />
  29.  
  30. <!-- This produces a container-managed EntityManagerFactory;
  31. rather than application-managed EntityManagerFactory as in case of LocalEntityManagerFactoryBean-->
  32. <bean id="entityManagerFactoryBean" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  33. <property name="dataSource" ref="dataSource" />
  34.  
  35. <!-- This makes /META-INF/persistence.xml is no longer necessary -->
  36.  
  37. <property name="packagesToScan" value="com.controller"/>
  38. <!-- JpaVendorAdapter implementation for Hibernate EntityManager.
  39. Exposes Hibernate's persistence provider and EntityManager extension interface -->
  40. <property name="jpaVendorAdapter">
  41. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
  42. </property>
  43. <property name="jpaProperties">
  44. <props>
  45. <prop key="hibernate.hbm2ddl.auto">update</prop>
  46. <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
  47. </props>
  48. </property>
  49. </bean>
  50.  
  51. <!-- Simple implementation of the standard JDBC DataSource interface,
  52. configuring the plain old JDBC DriverManager via bean properties -->
  53. <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  54. <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  55. <property name="url" value="jdbc:mysql://localhost:3306/student" />
  56. <property name="username" value="root" />
  57. <property name="password" value="root" />
  58. </bean>
  59.  
  60. <!-- This transaction manager is appropriate for applications that use a single JPA EntityManagerFactory for transactional data access.
  61. JTA (usually through JtaTransactionManager) is necessary for accessing multiple transactional resources within the same transaction. -->
  62. <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  63. <property name="entityManagerFactory" ref="entityManagerFactoryBean" />
  64. </bean>
  65.  
  66. <!-- responsible for registering the necessary Spring components that power annotation-driven transaction management;
  67. such as when @Transactional methods are invoked -->
  68. <tx:annotation-driven />
  69.  
  70. </beans>
Add Comment
Please, Sign In to add comment