GithubHelp home page GithubHelp logo

Comments (7)

xy-peng avatar xy-peng commented on June 8, 2024

设计就是只能有一个自动下载微信支付平台证书的配置。

看代码不知道你是怎么做的,将它作为全局变量或者单例试试

from wechatpay-java.

625609414 avatar 625609414 commented on June 8, 2024

设计就是只能有一个自动下载微信支付平台证书的配置。

看代码不知道你是怎么做的,将它作为全局变量或者单例试试

我已经用了单例了,只是测试接口的时候初始化了商户号配置,程序终止了后,我又启动了想再测试一次,它就报商户配置已初始化,无法初始化的错误。但是程序重启了,我一直就获取不到配置了

from wechatpay-java.

deyun93 avatar deyun93 commented on June 8, 2024

我也出现类似情况

from wechatpay-java.

xy-peng avatar xy-peng commented on June 8, 2024

RSAAutoCertificateConfig 是不能重复配置,只能有一个实例的。

能否提供更详细的信息 @deyun93 ,无法判断你所说的是什么状况和具体原因。

from wechatpay-java.

625609414 avatar 625609414 commented on June 8, 2024

RSAAutoCertificateConfig 是不能重复配置,只能有一个实例的。

能否提供更详细的信息 @deyun93 ,无法判断你所说的是什么状况和具体原因。

image
你好,这里用了单例,但是现在我的问题是:我启动项目生成了商户号配置,测试接口也成功了。但是我重启了项目,又需要下载商户号配置,他就会提示我已经初始化了配置。

from wechatpay-java.

xy-peng avatar xy-peng commented on June 8, 2024

@625609414 是不是启动时,有多个地方并发调用了 WechatPayUtil.setConfigAndService

你的单例在多线程时,很可能会产生多个实例,这样就异常了。

参考参考线程安全的单例。我在你基础上改了一下,没测试,你可以试试。

public class ConfigSingleton {

  private static final ConfigSingleton instance;
  private final RSAAutoCertificateConfig config;

  static {
    instance = new ConfigSingleton();
  }

  private ConfigSingleton() {
    // 用商户私钥等信息初始化
    config = new RSAAutoCertificateConfig.Builder().build();
  }

  public static ConfigSingleton getInstance() {
    return instance;
  }

  public RSAAutoCertificateConfig getConfig() { return config; }
}

from wechatpay-java.

deyun93 avatar deyun93 commented on June 8, 2024

你可以试试。

目前自己修改了一下代码可以用了,你给的方法我也试试,比我写得优雅一点,谢谢

from wechatpay-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.