spring cloud 引入公共项目jar,可以访问controller以及相同数据库mybatis

背景:

我们开发bi组件,作为公共产品,其中包含数据包,图表,图册对应的功能接口。

包含mvc一套

而后续为了推广到各个省份,但是bi工具平台依然在更新功能,那么这里以jar包引入到其他业务省份。

1. 在pom中引入bi产品项目

<dependency>
			<groupId>com.boco.mpss</groupId>
  			<artifactId>MPSS-BI</artifactId>
			<version>${project.version}</version>
</dependency>

2. 在application启动类增加注解

@ComponentScan(basePackages = {
    "com.boco" })

这样就可以访问controller了、

3. 但是我在测试的时候发现访问mybatis的时候,报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.boco.wbs.function.custom.dao.CustomMapper.getAddress

找不到对应的xml

解决方案:

修改yml配置文件

修改前是这样写的读本地xml

mybatis:
  configuration:
    aggressive-lazy-loading: 'false'
    cache-enabled: 'true'
    default-executor-type: REUSE
    default-statement-timeout: 25000
    lazy-loading-enabled: 'false'
    multiple-result-sets-enabled: 'true'
    call-setters-on-nulls: true
  mapper-locations: classpath:mybatis/*.xml   -- 这里是这样读取本地

修改后可以读到jar中

  mapper-locations: classpath*:mybatis/*.xml

在classpath后面增加  * 就可以了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值