<build>
<finalName>ssm_template</finalName>
<!--设置mapper.xml配置与mapper类处于同个包下,否则编译时候无法生成到同一目录下,会报BindingException-->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<!-- 配置Tomcat7插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>
<!-- 配置打包时跳过测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
</plugin>
</plugins>
</build>
</project>
(二)applicationContext.xml的配置
1、applicationContext_dao.xml(数据库)的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
">
<!-- dao层 数据库连接部分-->
<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:properties/db.properties" />
<!-- 数据库连接池 -->
<bean destroy-method="close">
<property value="${jdbc.driver}" />
<property value="${jdbc.url}" />
<property value="${jdbc.username}" />
<property value="${jdbc.password}"/>
<!-- 连接池的最大数据库连接数 -->
<property value="10" />
<!-- 最大空闲数 -->
<property value="5" />
</bean>
<!-- 配置SqlSessionFactory单例 -->
<bean>
<!-- 配置数据源 -->
<property ref="dataSource" />
<!-- 加载mybatis核心配置文件 -->
<property value="classpath:mybatis/SqlMapConfig.xml" />
<!--别名包扫描-->
<property value="com.cenobitor.pojo"/>
</bean>
<!-- 动态代理dao配置,包扫描(推荐方式)-->
<bean>
<!-- 支持多包配置,多包时用,或者;分隔 -->
<property value="com.cenobitor.mapper" />
</bean>
</beans>
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?characterEncoding=utf-8
jdbc.username=root
jdbc.password=
2、applicationContext_service.xml(service扫描)的配置