ssh中applicationContext.xml配置

ssh中applicationContext.xml配置

    
    在ssh中,applicationContext.xml是默认是需要放到:WEB-INF 目录下的:
    
    

<?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:p="http://www.springframework.org/schema/p"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


 <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName"
   value="com.mysql.jdbc.Driver">
  </property>
  <property name="url" value="jdbc:mysql://localhost:3306/ssh"></property>
  <property name="username" value="root"></property>
  <property name="password" value="root"></property>
 </bean>
 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref bean="dataSource" />
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">
     org.hibernate.dialect.MySQLDialect
    </prop>
   </props>
  </property>
  <property name="mappingResources">
   <list>
    <value>com/wsw/ssh/model/User.hbm.xml</value></list>
  </property>
 </bean>
 
 <bean id="userDAOImpl" class="com.wsw.ssh.dao.impl.UserDAOImpl">
  <property name="sessionFactory">
   <ref bean="sessionFactory" />
  </property>
 </bean>
 <bean id="userServiceImpl" class="com.wsw.ssh.service.impl.UserServiceImpl">
  <property name="userDAO">
   <ref bean="userDAOImpl"/>
  </property>
 </bean>
 
 <bean id="userAction" class="com.wsw.ssh.action.UserAction">
  <property name="userService">    <!--userService 表示在此类中使用userService 对象属性(还需要get和set方法),而不是userService 类-->
   <ref bean="userServiceImpl"/>
  </property>
 </bean>
 </beans>

你可能感兴趣的:(ssh中applicationContext.xml配置)