0.WEB-INF结构:
WEB-INF
- web.xml
- tickets-servlet.xml
- business-config.xml
完成后:将数据库相关的配置单独列出xml文件,便于管理。在entities包内的实体(Entity)、仓库(Repository)类注解都会被自动注入。
1.新建business-config.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<!-- Notice the URL about jpa, it is easy to be ignored. -->
<mvc:annotation-driven/>
<context:component-scan base-package="co