標籤:bsp method basic data utf-8 nal factor beans http
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.xsd10 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd11 http://www.springframework.org/schema/mvc12 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 <bean24 class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />25 <bean26 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