Created
May 3, 2019 04:29
-
-
Save darbyluv2code/77bb03ef7a610784b7e9cb6d6318d12c to your computer and use it in GitHub Desktop.
spring-mvc-crud-demo-servlet.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <beans xmlns="http://www.springframework.org/schema/beans" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xmlns:context="http://www.springframework.org/schema/context" | |
| xmlns:tx="http://www.springframework.org/schema/tx" | |
| xmlns:mvc="http://www.springframework.org/schema/mvc" | |
| xsi:schemaLocation=" | |
| http://www.springframework.org/schema/beans | |
| http://www.springframework.org/schema/beans/spring-beans.xsd | |
| http://www.springframework.org/schema/context | |
| http://www.springframework.org/schema/context/spring-context.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"> | |
| <!-- Step 3: Add support for component scanning --> | |
| <context:component-scan base-package="controller,DAO" /> | |
| <!-- Step 4: Add support for conversion, formatting and validation support --> | |
| <mvc:annotation-driven/> | |
| <!-- Step 5: Define Spring MVC view resolver --> | |
| <bean | |
| class="org.springframework.web.servlet.view.InternalResourceViewResolver"> | |
| <property name="prefix" value="/WEB-INF/view/" /> | |
| <property name="suffix" value=".jsp" /> | |
| </bean> | |
| <!-- Step 1: Define Database DataSource / connection pool --> | |
| <bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" | |
| destroy-method="close"> | |
| <property name="driverClass" value="com.mysql.cj.jdbc.Driver" /> | |
| <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/web_customer_tracker?useSSL=false&serverTimezone=UTC" /> | |
| <property name="user" value="springstudent" /> | |
| <property name="password" value="springstudent" /> | |
| <!-- these are connection pool properties for C3P0 --> | |
| <property name="minPoolSize" value="5" /> | |
| <property name="maxPoolSize" value="20" /> | |
| <property name="maxIdleTime" value="30000" /> | |
| </bean> | |
| <!-- Step 2: Setup Hibernate session factory --> | |
| <bean id="sessionFactory" | |
| class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> | |
| <property name="dataSource" ref="myDataSource" /> | |
| <property name="packagesToScan" value="entity" /> | |
| <property name="hibernateProperties"> | |
| <props> | |
| <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> | |
| <prop key="hibernate.show_sql">true</prop> | |
| </props> | |
| </property> | |
| </bean> | |
| <!-- Step 3: Setup Hibernate transaction manager --> | |
| <bean id="myTransactionManager" | |
| class="org.springframework.orm.hibernate5.HibernateTransactionManager"> | |
| <property name="sessionFactory" ref="sessionFactory"/> | |
| </bean> | |
| <!-- Step 4: Enable configuration of transactional behavior based on annotations --> | |
| <tx:annotation-driven transaction-manager="myTransactionManager" /> | |
| <!-- adding images --> | |
| <!-- <mvc:resources location="/resources/" mapping="/resources/**"></mvc:resources> | |
| <util:properties id="countryoptions" location="classpath:../countries.properties"></util:properties> --> | |
| </beans> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment