[Maven] Hibernate + Spring werken niet

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Web.xml

      XML Source Code

      1. <?xml version="1.0" encoding="UTF-8"?>
      2. <web-app xmlns="http://java.sun.com/xml/ns/javaee"
      3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      5. version="3.0">
      6. <!-- Setup servlet -->
      7. <servlet>
      8. <servlet-name>appServlet</servlet-name>
      9. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      10. <init-param>
      11. <param-name>contextConfigLocation</param-name>
      12. <param-value>/WEB-INF/servlet-context.xml</param-value>
      13. </init-param>
      14. <load-on-startup>1</load-on-startup>
      15. </servlet>
      16. <servlet-mapping>
      17. <servlet-name>appServlet</servlet-name>
      18. <url-pattern>/</url-pattern>
      19. </servlet-mapping>
      20. <!-- Setup the timeout handler -->
      21. <session-config>
      22. <session-timeout>
      23. 30
      24. </session-timeout>
      25. </session-config>
      26. <!-- Welcome JSP -->
      27. <welcome-file-list>
      28. <welcome-file>redirect.jsp</welcome-file>
      29. </welcome-file-list>
      30. </web-app>
      Display All


      En natuurlijk hoort hier die servlet context ook bij...

      XML Source Code

      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. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      7. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
      8. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
      9. ">
      10. <!-- Map simple view name such as "test" into /WEB-INF/views/test.jsp -->
      11. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      12. <property name="prefix" value="/Views/" />
      13. <property name="suffix" value=".jsp" />
      14. </bean>
      15. <!-- Scan classpath for annotations (eg: @Service, @Repository etc) -->
      16. <context:component-scan base-package="com.socialacademy" />
      17. <!-- Load properties -->
      18. <context:property-placeholder location="classpath:socialacademy.properties" />
      19. <!-- JDBC Data Source. It is assumed you have MySQL running on localhost port 3306 with
      20. username root and blank password. Change below if it's not the case -->
      21. <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      22. <property name="driverClassName" value="${jdbc.driverClassName}"/>
      23. <property name="url" value="${jdbc.url}" />
      24. <property name="username" value="${jdbc.user}" />
      25. <property name="password" value="${jdbc.pass}" />
      26. <property name="validationQuery" value="SELECT 1" />
      27. </bean>
      28. <!-- Hibernate Session Factory -->
      29. <bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
      30. <property name="dataSource" ref="myDataSource" />
      31. <property name="packagesToScan" value="com.socialacademy.model" />
      32. <property name="hibernateProperties">
      33. <props>
      34. <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
      35. <prop key="hibernate.dialect">${hibernate.dialect}</prop>
      36. </props>
      37. </property>
      38. </bean>
      39. <!-- Hibernate Transaction Manager -->
      40. <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
      41. <property name="sessionFactory" ref="mySessionFactory" />
      42. </bean>
      43. <!-- Activates annotation based transaction management -->
      44. <tx:annotation-driven transaction-manager="transactionManager" />
      45. </beans>
      Display All
      Dit was mijn spreekbeurt, zijn er nog vragen?