1.tomcat项目在web.xml文件中设置默认启动页
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
2.xxxMapper.xml文件头
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mapper接口的包名+类名">
<mapper>
3.sqlMapConfig.xml配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--引入数据库,即jdbc配置文件-->
<properties resource="jdbc.properties"/>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
<!--配置别名com.hp.entity.User-->
<typeAliases>
<package name="com.hp.entity"/>
</typeAliases>
<!--分页拦截器-->
<plugins>
<!--mybatis分页拦截器-->
<plugin interceptor="com.github.pagehelper.PageInterceptor"/>
</plugins>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<!--如果报绑定的错误,在resource中创建文件夹,以“/”分割,和mapper接口同包-->
<package name="com.hp.mapper"/>
<!-- <mapper resource="mapper/UserMapper.xml"/>-->
<!-- <mapper resource="mapper/GoodsMapper.xml"/>-->
</mappers>
</configuration>

4.application.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
5.application.xml中的bean
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd">
<!--
反射的目的是拿到实现类的信息,然后根据newInstance创建对象,所以class只能是实现类的全路径
过程:
1.创建applicationContext.xml配置文件
2.xml中定义我们的对象,告诉容器(applicationContext),我需要你帮我创建该bean
bean规则:
id="xxx" id必须唯一
class:类的完全路径,必须是普通类,如User,UserDaoImpl等,一定不能是接口
3.容器会把bean信息解析成一个Map<id,对象> mao
id -> userDao
对象 -> 通过反射生成的对象UserDapImpl
4.applicationContext.getBean("id") -> 就认为根据id去取map中获取相对应的对象
-->
<!--
scope:设置单例还是多例
singleton:单例
prototype:多例
-->
<!--
告诉spring容器,当你加载xml文件的时候,就帮我创建,赋值user对象
property赋值属于set赋值
-->
<bean id="address" class="com.hp.entity.Address">
<property name="detail" value="000000"/>
<property name="postCode" value="郑州"/>
</bean>
<bean id="user" class="com.hp.entity.User">
<property name="name" value="张三"/>
<property name="age" value="21"/>
<property name="sex" value="女"/><!--默认User中有Sex属性,并且有setSex(xxx)方法-->
<property name="address" ref="address"/><!--传入引用数据类型-->
</bean>
<bean id="userDao" class="com.hp.dao.impl.UserDaoImpl"/>
<bean id="userService" class="com.hp.service.impl.UserServiceImpl">
<property name="dao" ref="userDao"/>
</bean>
</beans>