defined in com.dibao.repository.AnchorAmountRepository defined in @EnableJpaRepositories declared on

这个错误信息表明,在你的 Spring 应用程序中,AnchorAmountRepository 的初始化失败了,具体是因为调用了 net.sf.jsqlparser.expression.Function.withName(Ljava/lang/String;)Lnet/sf/jsqlparser/expression/Function; 方法时找不到这个方法。这通常是由于 JSQLParser 库的版本不匹配导致的。

解决方法

  1. 检查依赖版本
    确保你项目中使用的 JSQLParser 版本正确且一致。查看你的 pom.xml 文件或 build.gradle 文件,确保 JSQLParser 版本与其他库兼容。例如:

    <dependency>
        <groupId>com.github.jsqlparser</groupId>
        <artifactId>jsqlparser</artifactId>
        <version>4.0</version>
    </dependency>
    

    确保 version 标签中的版本号与项目中其他库兼容。

  2. 排除冲突的依赖
    有时其他库可能引入了不同版本的 JSQLParser,导致冲突。你可以使用 Maven 的 dependency:tree 命令查看依赖树,找出可能的冲突:

    mvn dependency:tree
    

    然后在 pom.xml 中排除冲突的版本:

    <dependency>
        <groupId>com.example</groupId>
        <artifactId>example-artifact</artifactId>
        <version>1.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.github.jsqlparser</groupId>
                <artifactId>jsqlparser</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
  3. 更新依赖
    更新 JSQLParser 到最新版本,或更新与 JSQLParser 相关的库,以确保兼容性。可以在 Maven Central 或者官方仓库中查找最新版本。

  4. 重新构建项目
    有时缓存可能会导致依赖问题。尝试清理并重新构建项目:

    mvn clean install
    

具体示例

假设你的 pom.xml 文件中 JSQLParser 版本为 4.0,而你需要更新到 4.2:

<dependency>
    <groupId>com.github.jsqlparser</groupId>
    <artifactId>jsqlparser</artifactId>
    <version>4.2</version>
</dependency>

如果存在其他库引入了不同版本的 JSQLParser,可以排除这些依赖:

<dependency>
    <groupId>com.example</groupId>
    <artifactId>example-artifact</artifactId>
    <version>1.0</version>
    <exclusions>
        <exclusion>
            <groupId>com.github.jsqlparser</groupId>
            <artifactId>jsqlparser</artifactId>
        </exclusion>
    </exclusions>
</dependency>

通过以上步骤,你应该能够解决 NoSuchMethodError 问题,确保 JSQLParser 版本一致且兼容。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值