背景:

我们开发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后面增加  * 就可以了

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐