spring-boot下mybatis的配置

問題描述:spring boot項目想添加mybatis的配置,在src/main/resources目錄下新建了mybatis-config.xml文件,在application.properties文件中添加:java

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

本地啓動沒有問題,可是使用jenkins構建打包後老是報錯:spring

[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文件的位置。改動後爲:sql

<resources>
	<resource>
		<directory>src/main/java</directory>
	</resource>
	<!--指定資源的位置 -->
	<resource>
		<directory>src/main/resources</directory>
		<includes>
			<include>**/*.xml</include>
			<include>**.properties</include>
		</includes>
	</resource>
</resources>
相關文章
相關標籤/搜索