spring3+hibernate4配置文件

原创 2016年08月29日 11:21:24
<span style="font-size:14px;">applicationContext.xml</span>
<?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:mvc="http://www.springframework.org/schema/mvc"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc
    	http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    	http://www.springframework.org/schema/context
    	http://www.springframework.org/schema/context/spring-context.xsd
    	http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd">


	<!-- Data source -->
	<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property name="url"
			value="jdbc:mysql://localhost:3306/testermonitor?useUnicode=true&characterEncoding=UTF-8" />
		<property name="username" value="wangkha" />
		<property name="password" value="wangkaihong" />
	</bean>


	<!-- Hibernate -->
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan" value="com.sugon.parastor.model" />
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="current_session_context_class">thread</prop>
				<prop key="show_sql">true</prop>
			</props>
		</property>
		


	</bean>
	
	<!-- transactionManager -->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
		<property name="dataSource" ref="dataSource" />
	</bean>
	
	<tx:annotation-driven transaction-manager="transactionManager" />


	<!-- Component scan -->
	<context:component-scan base-package="com.sugon.parastor.model" />
	<context:component-scan base-package="com.sugon.parastor.dao" />


</beans>


web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="WebApp_ID" version="3.0">
	<display-name>TesterMonitor</display-name>
	<welcome-file-list>
		<welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
	</welcome-file-list>
	
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>classpath:log4j.properties</param-value>
	</context-param>
	
	<!-- Spring ApplicationContext配置文件的路径,可使用通配符,多个路径用,号分隔 此参数用于后面的Spring Context 
		Loader -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>  
            classpath:/applicationContext.xml
        </param-value>
	</context-param>

	<!--Spring的ApplicationContext 载入 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- Spring MVC -->
	<servlet>
		<servlet-name>monitor</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>monitor</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>

</web-app>


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Struts2+Spring3+Hibernate4整合之Spring配置文件

applicationContext.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="ht...

spring3 配置文件

http://www.springframework.org/schema/beans"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...

Spring3-多个配置文件的整合

在大型的Spring3项目中,所有的Bean配置在一个配置文件中不易管理,也不利于团队开发,通常在开发过程中,我们会按照功能模块的不同,或者开发人员的不同,将配置文件分成多个,这样有利于模块的划分。本...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)