<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!--配置数据库-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost/leehuan</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>lihuan</value></property>
</bean>
<!--引入SessionFactory-->
<bean id="SessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!--引入配好的数据库结构-->
<property name="dataSource" ref="dataSource"></property>
<!--导入hiernate映射的xml-->
<property name="mappingResources">
<list>
<value>com/leehuan/bena/User-hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<!--配置habernate官方语言-->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<!--使其控制台输出sql语句-->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!--此类中实现了SessinFactory实例-->
<bean id="UserDao" class="com.leehuan.bena.imp.Userimp">
<property name="sessionFactory" ref="SessionFactory"></property>
</bean>
<!--在设置Action时,在struts.xml中Class不再使用全包名类,而是使用此id-->
<bean id="Useraction" class="com.leehuan.action.UserAction" scope="prototype">
<property name="name" value="Hello world"></property>
</bean>
</beans>
SSH框架applicationContext.xml简单配置
最新推荐文章于 2019-10-17 19:01:45 发布