ssm applicationContent.xml
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssm applicationContent.xml相关的知识,希望对你有一定的参考价值。
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 5 xmlns:mvc="http://www.springframework.org/schema/mvc" 6 xsi:schemaLocation=" 7 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 8 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 9 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 10 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 11 http://www.springframework.org/schema/mvc 12 http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 13 14 15 <mvc:annotation-driven /> 16 <!-- 开启扫描,扫描所有的配置文件,以Controller注解的除外 --> 17 <context:component-scan base-package="com.jlncrm"> 18 </context:component-scan> 19 20 <!-- 以下是Spring MVC + Spring的全注解配置 --> 21 22 <!-- Spring MVC 的所有配置 --> 23 <bean 24 class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" /> 25 <bean 26 class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" /> 27 28 <mvc:default-servlet-handler /> 29 <!-- 静态资源处理 --> 30 <mvc:resources mapping="/static/**" location="/WEB-INF/static/" /> 31 32 <!-- 默认的视图解析器 在上边的解析错误时使用 (默认使用html)- --> 33 <bean id="defaultViewResolver" 34 class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 35 <property name="viewClass" 36 value="org.springframework.web.servlet.view.JstlView" /> 37 <property name="contentType" value="text/html" /> 38 <property name="prefix" value="/WEB-INF/jsp/" /> 39 <property name="suffix" value=".jsp" /> 40 </bean> 41 42 <!-- 以下是Spring + Mybatis的全注解配置 --> 43 44 <tx:annotation-driven transaction-manager="txManager" /> 45 46 <!-- 注册事务管理 --> 47 <bean id="txManager" 48 class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 49 <property name="dataSource" ref="dataSource" /> 50 </bean> 51 52 <!-- 定义dbcp数据源 --> 53 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 54 <!-- 指定JDBC驱动类 --> 55 <property name="driverClassName" value="com.mysql.jdbc.Driver"> 56 </property> 57 <!-- 提供连接数据库的URL地址 --> 58 <property name="url" value="jdbc:mysql://localhost:3306/crm"> 59 </property> 60 <!-- 提供连接数据库的用户名和密码 --> 61 <property name="username" value="root"></property> 62 <property name="password" value="123456"></property> 63 </bean> 64 65 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 66 <property name="dataSource" ref="dataSource" /> 67 <property name="mapperLocations" value="classpath*:mapper/*Mapper.xml" /> 68 </bean> 69 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 70 <property name="basePackage" value="com" /> 71 <property name="annotationClass" value="org.springframework.stereotype.Repository"></property> 72 </bean> 73 74 </beans>
以上是关于ssm applicationContent.xml的主要内容,如果未能解决你的问题,请参考以下文章