启动项目报错
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean of type 'com.itsm.email.dao.AreaMapper' that could not be found.
Action:
Consider defining a bean of type 'com.itsm.email.dao.AreaMapper' in your configuration
目录结构
这句话的意思是找不到这个mapper.xml对应的java类
解决办法在启动类上加上
@MapperScan("com.itsm.email.dao")
必须指定到dao这一级目录,连同java类一同扫描进入,否则不会生效
到此,启动没问题,但是访问时报错
Invalid bound statement (not found): com.itsm.email.dao.AreaMapper.find
怀疑是mapper文件没有指定,在application.properties中加入
mybatis.mapper-locations=classpath:com/itsm/email/dao/mapper/*.xml
还不行,推测是不是.xml没扫描进入,看下target文件夹果然没有
在pom build中加入
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
至此访问成功