关于mapper接口与mapper.xml文件在同包运行找不到问题解决


springboot中解决方案一:

将mapper映射文件放到resources下,必须与mapper接口相同结构,并且在主启动类添加@MapperScan("com.offcn.mapper")注解扫描包

 

 

 

解决方案二:

直接在pom.xml中配置插件

<!--将java目录下的.xml/.properties文件复制到resources目录下-->

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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM