Advertisement
Guest User

Untitled

a guest
Sep 18th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
  5. xmlns:tx="http://www.springframework.org/schema/tx"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  8. http://www.springframework.org/schema/context
  9. http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
  10. <tx:annotation-driven transaction-manager="transactionManager"/>
  11. <mvc:annotation-driven/>
  12. <mvc:resources mapping="/resources/**" location="/resources/"/>
  13. <context:component-scan base-package="ru, ru.instance" />
  14. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  15. <property name="prefix" value="/WEB-INF/pages/"/>
  16. <property name="suffix" value=".jsp"/>
  17. </bean>
  18.  
  19. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
  20. <property name="driverClassName" value="org.springframework.jdbc.datasource.DriverManagerDataSource"/>
  21. <property name="url" value="jdbc:mysql://localhost/:3306/OrganizerDB?useSSL=false"/>
  22. <property name="username" value="sasha"/>
  23. <property name="password" value="sasha"/>
  24. </bean>
  25. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  26. <property name="dataSource" ref="dataSource"/>
  27. <property name="packagesToScan" value="ru.instance"/>
  28. <property name="annotatedPackages" value="ru.instance"/>
  29. <property name="hibernateProperties">
  30. <props>
  31. <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
  32. <prop key="hibernate.show_sql">true</prop>
  33. </props>
  34. </property>
  35. </bean>
  36. <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  37. <property name="sessionFactory" ref="sessionFactory"/>
  38. </bean>
  39.  
  40. @Transactional
  41. public class UsersClass{
  42. private static final Logger _log = LogManager.getLogger(UsersClass.class.getName());
  43.  
  44. @Autowired
  45. private SessionFactory sessionFactory;
  46.  
  47. public void getAll() {
  48. System.out.println("Sesion: " + this.sessionFactory);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement