Advertisement
Guest User

Untitled

a guest
Oct 28th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 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:tx="http://www.springframework.org/schema/tx"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc"
  7. xsi:schemaLocation="
  8. http://www.springframework.org/schema/beans
  9. http://www.springframework.org/schema/beans/spring-beans.xsd
  10. http://www.springframework.org/schema/context
  11. http://www.springframework.org/schema/context/spring-context.xsd
  12. http://www.springframework.org/schema/mvc
  13. http://www.springframework.org/schema/mvc/spring-mvc.xsd
  14. http://www.springframework.org/schema/tx
  15. http://www.springframework.org/schema/tx/spring-tx.xsd">
  16.  
  17. <!-- Add support for component scanning -->
  18. <context:component-scan base-package="pl.marcin" />
  19.  
  20. <!-- Add support for conversion, formatting and validation support -->
  21. <mvc:annotation-driven/>
  22.  
  23. <!-- Define Spring MVC view resolver -->
  24. <bean
  25. class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  26. <property name="prefix" value="/WEB-INF/view/" />
  27. <property name="suffix" value=".jsp" />
  28. </bean>
  29.  
  30. <!-- Step 1: Define Database DataSource / connection pool -->
  31. <bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
  32. destroy-method="close">
  33. <property name="driverClass" value="com.mysql.cj.jdbc.Driver" />
  34. <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/web_tracker?useSSL=false&amp;serverTimezone=UTC" />
  35. <property name="user" value="spring" />
  36. <property name="password" value="spring" />
  37.  
  38. <!-- these are connection pool properties for C3P0 -->
  39. <property name="minPoolSize" value="5" />
  40. <property name="maxPoolSize" value="20" />
  41. <property name="maxIdleTime" value="30000" />
  42. </bean>
  43.  
  44. <!-- Step 2: Setup Hibernate session factory -->
  45. <bean id="sessionFactory"
  46. class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  47. <property name="dataSource" ref="myDataSource" />
  48. <property name="packagesToScan" value="pl.marcin.entity" />
  49. <property name="hibernateProperties">
  50. <props>
  51. <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  52. <prop key="hibernate.show_sql">true</prop>
  53. </props>
  54. </property>
  55. </bean>
  56.  
  57. <!-- Step 3: Setup Hibernate transaction manager -->
  58. <bean id="myTransactionManager"
  59. class="org.springframework.orm.hibernate5.HibernateTransactionManager">
  60. <property name="sessionFactory" ref="sessionFactory"/>
  61. </bean>
  62.  
  63. <!-- Step 4: Enable configuration of transactional behavior based on annotations -->
  64. <tx:annotation-driven transaction-manager="myTransactionManager" />
  65.  
  66. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement