<!--在控制台输出sql语句日志-->
<settings>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
<typeAliases>
<!--给包起别名 别名就是类名-->
<package name="com.wanshi.pojo"/>
<!--给实体类起别名-->
<typeAlias type="com.wanshi.pojo.Users" alias="users"></typeAlias>
</typeAliases>
<小于<
>大于>
<!--
association:一对一查询配置,查询订单的同时通过得到的用户id查询出该订单对应的用户信息
property:在Order实体类中封装的user属性名称
javaType:在Order实体类中封装的user真实指向的实体类是谁
select:引用当前xml文件中的某一个查询sql片段
column:使用哪个列的值
-->
<!--
collection:一对多关联配置,先执行查询用户,再根据用户的id查询出该用户对应的订单返回的数据形成集合
property:返回的订单集合映射到User实体类中的orderList身上,所以这里要写orderList
select:要引用的查询片段
singleton:默认值,以单例的方式创建对象(地址不变)
prototype:以多例的方式创建对象(地址会变 相当于new)
--
xml顶部
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper></mapper>
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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<bean></bean>
bean标签:意思是将某一个实体类配置为spring容器管理的类,该类的对象由spring容器来进行创建
id属性:给这个Bean起个名字并且其他的bean的名字不能和它重复,以这个名字来最终获取到对象
class属性:我们要将哪个类配置给spring容器管理,要写全包名+类名
scope属性:规定bean的创建方式是单例的还是多例的,以及创建完放哪
singleton:默认值,以单例的方式创建对象(地址不变)
prototype:以多例的方式创建对象(地址会变 相当于new)
面试题:spring容器管理的bean是单例还是多例的,有区别,有什么影响
单例的对象:可能会产生数据安全性问题
多例的对象:数据各自是各自的,不会产生数据安全问题