spring-boot下mybatis的配置

问题描述:spring boot项目想添加mybatis的配置,在src/main/resources目录下新建了mybatis-config.xml文件,在application.properties文件中添加:

mybatis.config-location=classpath:mybatis-config.xml

本地启动没有问题,但是使用jenkins构建打包后总是报错:

[org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.io.FileNotFoundException: class path resource [mybatis-config.xml] cannot be opened because it does not exist

找不到mybatis-config.xml的配置文件。kenjins构建使用的是maven打包,于是找到pom文件,发现没有指定xml文件的位置。改动后为:

<resources>
	<resource>
		<directory>src/main/java</directory>
	</resource>
	<!--指定资源的位置 -->
	<resource>
		<directory>src/main/resources</directory>
		<includes>
			<include>**/*.xml</include>
			<include>**.properties</include>
		</includes>
	</resource>
</resources>

转载于:https://my.oschina.net/wuyiyi/blog/2885638

原文地址:https://www.cnblogs.com/twodog/p/12135582.html