applicationContext.xml 配置(扫描)
<?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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 数据库连接 -->
<bean id="mydatasource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="root">
</property>
<property name="password" value="mysqladmin">
</property>
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/kingslanding">
</property>
</bean>
<!-- 返回json 方法 需要导入 jackson-annotations.jar,jackson-core.jar,jackson-databind.jar-->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html; charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html; charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
<!-- 在Spring中生成一个sqlsessionfactory对象 -->
<bean id="sqlsessionfactorybean" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="mydatasource">
</property>
<property name="mapperLocations" value="classpath:org/kingsanding/dao/*/*.xml">
</property>
</bean>
<!-- 根据MapperDao生成Dao对象实例 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.kingsanding.dao">
</property>
<!-- 指定@MyBatisDao所在位置 -->
<property name="annotationClass" value="org.kingsanding.utils.MyBatisDao">
</property>
<!-- 自动注入sqlsessionfactory -->
</bean>
<!-- Spring MVC -->
<!-- 启动Spring的组件自动扫描机制 -->
<context:component-scan base-package="org.kingsanding" />
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/">
</property>
<property name="suffix" value=".jsp">
</property>
</bean>
</beans>
applicationContext.xml 配置(扫描)的更多相关文章
- Spring的配置文件ApplicationContext.xml配置头文件解析
Spring的配置文件ApplicationContext.xml配置头文件解析 原创 2016年12月16日 14:22:43 标签: spring配置文件 5446 spring中的applica ...
- springmvc.xml和applicationContext.xml配置的特点
1:springmvc.xml配置要点 一般它主要配置Controller的组件扫描器和视图解析器 下为:springmvc.xml文件 <?xml version="1.0" ...
- applicationContext.xml配置简介
这里简单介绍一下spring的配置文件applicationContext.xml中的一些配置的作用. <context:component-scan base-package="&q ...
- 第九篇:Spring的applicationContext.xml配置总结
在前面的一篇日志中,记录了web.xml配置启动的顺序,web启动到监听器ContextLoaderListener时,开始加载spring的配置文件applicationContext.xml(通常 ...
- web.xml配置错误导致applicationContext.xml配置重复加载
web.xml相关配置 <context-param><param-name>log4jRefreshInterval</param-name><param- ...
- spring的applicationContext.xml配置SessionFactory抛异常
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFa ...
- 关于Spring中applicationContext.xml配置错误“org/springframework/transaction/interceptor/TransactionInterceptor”的问题解决
问题描述: 在配置spring的applicationContext.xml中的默认事务管理器的时候可能会出现这样的错误: Error occured processing XML 'org/spri ...
- Spring学习总结(7)——applicationContext.xml 配置文详解
web.xml中classpath:和classpath*: 有什么区别? classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件 ...
- applicationContext.xml配置AOP切面编程
Computer.java package com.wh.aop2; public class Computer { public void play01(){ System.out.println( ...
随机推荐
- oracle查询排序后的前几条记录
select * from (select * from table order by 字段名 desc) where rownum<你要查的记录条数,这样才能符合条件.
- Kruskal算法的简单实现
嘛嘛嘛,好像大家在实现Kruskal算法是都是用的边集数组,判断图的连通性咱不会,o(╯□╰)o(为什么咱这么菜诶) Kruskal算法: 规则: (1)对每一条边按照从小到大进行排序 (2)加入边的 ...
- non-ARC代码转 ARC 排除 “Existing instance variable 'delegate' for property with assign attribute must be _unsafe _unretained” 错误
原来非ARC代码是 @interface MHWebImageDownloader : NSObject { id<MHWebImageDownloaderDelegate> delega ...
- UEFI主板GPT方式安装CentOS6.4
1. 设置BIOS:禁用CSM,禁用安全启动: 或不用禁用CSM,但以EFI方式安装系统: 2. 使用Diskgen或类似工具把硬盘格式为GPT格式(可以建立多于4个的主分区了): 3. 官 ...
- 使用vs2010打开VS2013的工程文件
在开发团队,会出现vs工具使用版本的不一样的情况.我的电脑使用的是VS2010,可是其他人员使用的是vs2013. 要打开其他人员上传的工程文件,可以通过三种方式: 1.下载一个vs2013版本. 2 ...
- LWP::UserAgent介绍1
require LWP::UserAgent; my $ua = LWP::UserAgent->new; ); $ua->env_proxy; my $response = $ua-&g ...
- Java 语言的 XPath API
如果要告诉别人买一加仑牛奶,您会怎么说?"请去买一加仑牛奶回来" 还是 "从前门出去,向左转,走三个街区向右转,再走半个街区向右转进入商店.走向四号通道,沿通道走五米向左 ...
- 分布式版本控制系统Git-----5.Git 的push命令总结
git push git push命令用于将本地分支的更新,推送到远程主机.它的格式与git pull命令相仿. git push <远程主机名> <本地分支名>:<远程 ...
- ubuntu 安装python mysql模块
Installation Starting with a vanilla Lucid install , install pip and upgrade to the latest version: ...
- Impala:新一代开源大数据分析引擎
Impala架构分析 Impala是Cloudera公司主导开发的新型查询系统,它提供SQL语义,能查询存储在Hadoop的HDFS和HBase中的PB级大数据.已有的Hive系统虽然也提供了SQL语 ...