网络编程中的spring-servlet.xml文件

同上一篇一样,也是私人配置。

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-4.1.xsd
        http://www.springframework.org/schema/mvc 
 		http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">

  <!-- the application context definition for the springapp DispatcherServlet -->
   
   <context:component-scan base-package="com.myweb"></context:component-scan>
   <mvc:annotation-driven/>
   <mvc:resources mapping="/css/**" location="/bootstrap/css/"/>
   <mvc:resources mapping="/js/**" location="/bootstrap/js/"/>
   <mvc:resources mapping="/images/**" location="/images/"/>
   <mvc:default-servlet-handler />

  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"></property>
        <property name="suffix" value=".jsp"></property>        
  </bean>
   <!-- 
 <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
	<property name="mappings">
		<props>
			<prop key="/index">IndexAction</prop>                key是url后面的地址 
		</props>
	</property>
 </bean>  
 <bean id="IndexAction" class="com.myweb.IndexAction">
 <property name="view">
 <value>index</value>                                            对应到相应的jsp界面
 </property> 
 </bean>
   -->
 <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="jdbc:mysql://localhost:3306/myweb" />
     <property name="username" value="root" />
     <property name="password" value="root" />
 </bean>
   
 <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
	<property name="driverClassName" value="com.mysql.jdbc.Driver" />
	<property name="url" value="jdbc:mysql://localhost:3306/myweb?useUnicode=true&characterEncoding=utf-8" />
	<property name="username" value="root" />
	<property name="password" value="root" />
	
	<property name="filters" value="stat" />
	<!--最大连接数量 -->
	<property name="maxActive" value="20" />
	 <!--初始连接数 -->
	<property name="initialSize" value="5" />
 </bean> 
   
   <bean id="jb" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="dataSource" />
 </bean>
 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">      
 	<property name="dataSource" ref="dataSource"/>
 	<property name="mapperLocations" value="classpath:com/myweb/database/mapper/*.xml" />
 	<property name="typeAliasesPackage" value="com.myweb.database.model" />
 </bean>
<bean  class="org.mybatis.spring.mapper.MapperScannerConfigurer">
	<property name="basePackage" value="com.myweb.database.mapper"/>
	<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
   
</beans>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值