【Java】springboot maven多模块打包报dao模块mybatis mapper文件找不到,如何解决?
现在项目有三个模块:dao(mybatis)模块、service模块和web模块,我在project 的pom.xml文件是这样打包设置的:
<build><finalName>good-learning-success</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<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>
<configuration>
<!-- 指定该Main Class为全局的唯一入口 -->
<mainClass>com.qtay.gls.Application</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
打包也成功了,本地运行更没问题,但是我上传到服务器运行的时候:java -jar xxx就报:
2017-12-09 11:49:42.196 INFO [background-preinit] o.h.validator.internal.util.Version - HV000001: Hibernate Validator 5.3.5.Final2017-12-09 11:49:43.735 WARN [main] o.m.s.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.qtay.gls.dao]' package. Please check your configuration.
2017-12-09 11:49:44.040 WARN [main] o.m.s.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.qtay.gls.controller, com.qtay.gls]' package. Please check your configuratio
...]
回答
问题解决了:
解决方法是这样的,我把build相关配置从project 的pom.xml移到web module的pom.xml上面 再执行打包就ok了!
关键是project pom.xml和module pom.xml有什么区别吗,有人知道可以在下面回答探讨下
通过你给出的日志,我只能看出springboot启动时扫描不到dao层接口
我建议你在启动类里面加上mapper扫描注解,如@MapperScan("com.qtay.gls.dao")
以上是 【Java】springboot maven多模块打包报dao模块mybatis mapper文件找不到,如何解决? 的全部内容, 来源链接: utcz.com/a/89780.html