说明:1、jar中包含mapper信息,jar中的mapper与当前springboot项目的mapper不在一个包路径下面(当前springboot项目在不使用引入jar之前可以正常使用)

2、此记录为作者每执行一步修改一步的错误的过程,仅供参考


记录:

1、将jar包放到springboot项的resources->lib目录下;

直接启动,报错UnsatisfiedDependencyException...Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Location pattern must not be null

2、在启动类XXAplication中添加“@ComponentScan(value = {"com.xx"}) ”:com.xx指引入包的路径;

直接启动,报错Consider defining a bean of type 'com.xx.mapper.XXMapper' in your configuration.

3、在启动类XXAplication中添加“@MapperScan(basePackages={"com.xx.mapper"}”:com.xx.mapper指引入包的mapper路径;

直接启动,报错Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

4、在启动类XXAplication添加“DruidDataSourceAutoConfigure.class”,添加后如下:

@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
        DruidDataSourceAutoConfigure.class
})

直接启动,报错Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

5、上述问题作者直接注释了指定的代码(代码情况不同处理方式不同);

直接启动,报错...Location pattern must not be null;

6、找到制定的配置数据对应的java文件,修改配置错误名称(作者是配置名称修改了,没有修改对应java文件中的配置名称)

直接启动,报错Bean named 'redisCache' is expected to be of type 'org.springframework.data.redis.core.RedisTemplate' but was actually of type 'com.casco.framework.redis.RedisCache'

7、错误原因是在引入的jar包文件中redisCache:@Resource是默认取字段名进行按照名称注入,

将redisCache修改为redisTemplate

直接启动,报错@Resource annotation is not supported on static fields

8、将使用@Resource注解的字段取消static修饰

直接执行,jar正常加入


图片

 

 

 

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐