1、启动报错
APPLICATION FAILED TO START
Description:
Field iCsDataVerifyService in com.lonelywolf.boot.linuxdatasource.mydemo.controller.CsDataVerifyController required a bean of type ‘com.lonelywolf.boot.linuxdatasource.mydemo.mapper.CsDataVerifyMapper’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type ‘com.lonelywolf.boot.linuxdatasource.mydemo.mapper.CsDataVerifyMapper’ in your configuration.
找不到对应的文件:
a.在mapper文件中使用@mapper注解
b.或者在spring boot启动类中,使用@MapperScan(basePackages = {“com.lonelywolf.boot.linuxdatasource.mydemo.mapper”})
直接指定位置,也可以使用mapperScan注解效果是一样的
2、上面都弄好以后,启动时还可能出现以下问题
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
java.sql.SQLException: The connection property ‘zeroDateTimeBehavior’ acceptable values are: ‘CONVERT_TO_NULL’, ‘EXCEPTION’ or ‘ROUND’. The value ‘convertToNull’ is not acceptable.
是因为jdbc驱动包版本过高,(这里依赖的是8.**的版本)
切换为5.**的版本以后,正常启动
3、mybatis-plus代码生成器,生成的xml文件位置是与java文件在一块,可以移动到resource下,也可以不移动,不移动需要在pom.xml中,指定xml文件放在java目录下
</build>
<resources>
<resource>
<!-- xml放在java目录下-->
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>