pom.xml

		<dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>1.1.1</version>
		</dependency>
		<dependency>
			<groupId>commons-dbcp</groupId>
			<artifactId>commons-dbcp</artifactId>
			<version>1.4</version>
		</dependency>



        <build>
		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.xml</include>
				</includes>
				<filtering>false</filtering>
			</resource>

			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.*</include>
					<include>**/*</include>
				</includes>
				<filtering>true</filtering>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

注意上面的,如果你的mapper接口与xml文件是放在同一个目录下的,那需要注意配置上面的resource/main/java里要include你的xml文件。不然,编译后你会看到,并没有将xml文件拷贝过去.

application.properties

##mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=your-user-name
spring.datasource.password=your-user-passwd
spring.datasource.url=jdbc:mysql://mysql-host-ip:mysql-port/yoourDBName?useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
spring.datasource.dbcp.max-active=64
spring.datasource.dbcp.max-idle=64
spring.datasource.dbcp.max-wait=0
spring.datasource.dbcp.validation-query=select 1
spring.datasource.dbcp.test-while-idle=true
spring.datasource.dbcp.min-evictable-idle-time-millis=20000000
spring.datasource.dbcp.time-between-eviction-runs-millis=3600000

spring.datasource.type=org.apache.commons.dbcp.BasicDataSource


mybatis.config-location=classpath:mybatis-config.xml
mybatis.mapperLocations[0]=classpath:com/yourcompany/mapper/*.xml

使用

@Service
public class OperationLogService {

	@Autowired
	private OperationLogMapper operationLogMapper;
    ....
}