<!--Output sql statement log on the console-->
<settings>
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
<typeAliases>
<!--Alias for the package, the alias is the class name-->
<package name="com.wanshi.pojo"/>
<!--Alias for the entity class-->
<typeAlias type="com. wanshi.pojo.Users" alias="users"></typeAlias>
</typeAliases>
<less than<
>greater than>
<!--
association : One-to-one query configuration, while querying orders, query through the obtained user id Output the user information corresponding to the order
property : the name of the user attribute encapsulated in the Order entity class
javaType : who is the actual entity class pointed to by the user encapsulated in the Order entity class
select : refer to a certain query sql fragment
column in the current xml file : Which column value to use
-->
<!--
collection : One-to-many association configuration, first query the user, and then query the user's corresponding order according to the user id to form a collection property
: Returned order collection mapping To the orderList in the User entity class,So write orderList
select here : the query fragment to be referenced
singleton : default value, create an object as a singleton (address remains unchanged)
prototype : create an object as multiple instances (address will become equivalent to new)
--
xml top
<!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 tag : means to configure an entity class as a class managed by the spring container, and the objects of this class are composed of The spring container is used to create
the id attribute : give this bean a name and the names of other beans cannot be repeated with it, and use this name to finally obtain the object
class attribute : which class we want to configure for the spring container management, to write the full Package name + class name
scope attribute : Specifies whether the bean is created as a single instance or multiple instances, and where to place it after creation.
singleton: default value, create an object as a single instance (the address remains unchanged)
prototype : use multiple instances way to create an object (the address will become equivalent to new)
Interview question: Whether the bean managed by the spring container is a single instance or multiple instances, there is a difference, what will affect the
object of the single instance: it may cause data security problems
Multiple instances of the object: each data is its own, and will not cause data security question