Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns:mvc="http://www.springframework.org/schema/mvc"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
- xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <!-- It register the beans in context and scan the annotations inside beans and activate them --><!-- This allow for dispatching requests to Controllers -->
- <context:component-scan base-package="com.controller" />
- <mvc:annotation-driven />
- <!-- This helps in mapping the logical view names to directly view files under a certain pre-configured directory -->
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value="/WEB-INF/views/" />
- <property name="suffix" value=".jsp" />
- </bean>
- <!-- This resolves messages from resource bundles for different locales -->
- <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
- <property name="basename" value="messages" />
- </bean>
- <!-- To validate the posted add employee form -->
- <bean id="studentValidator" class="com.controller.validator.StudentValidator" />
- <!-- This produces a container-managed EntityManagerFactory;
- rather than application-managed EntityManagerFactory as in case of LocalEntityManagerFactoryBean-->
- <bean id="entityManagerFactoryBean" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <!-- This makes /META-INF/persistence.xml is no longer necessary -->
- <property name="packagesToScan" value="com.controller"/>
- <!-- JpaVendorAdapter implementation for Hibernate EntityManager.
- Exposes Hibernate's persistence provider and EntityManager extension interface -->
- <property name="jpaVendorAdapter">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
- </property>
- <property name="jpaProperties">
- <props>
- <prop key="hibernate.hbm2ddl.auto">update</prop>
- <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
- </props>
- </property>
- </bean>
- <!-- Simple implementation of the standard JDBC DataSource interface,
- configuring the plain old JDBC DriverManager via bean properties -->
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/student" />
- <property name="username" value="root" />
- <property name="password" value="root" />
- </bean>
- <!-- This transaction manager is appropriate for applications that use a single JPA EntityManagerFactory for transactional data access.
- JTA (usually through JtaTransactionManager) is necessary for accessing multiple transactional resources within the same transaction. -->
- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManagerFactoryBean" />
- </bean>
- <!-- responsible for registering the necessary Spring components that power annotation-driven transaction management;
- such as when @Transactional methods are invoked -->
- <tx:annotation-driven />
- </beans>
Add Comment
Please, Sign In to add comment