gpt4 book ai didi

java-money - 没有加载 MonetaryAmountsSingletonSpi

转载 作者:行者123 更新时间:2023-12-04 02:59:01 27 4
gpt4 key购买 nike

pom.xml 中添加的依赖:

<dependency>
<groupId>javax.money</groupId>
<artifactId>money-api</artifactId>
<version>1.0.3</version>
</dependency>

相关代码:

MonetaryAmount mon = Monetary.getDefaultAmountFactory()
//getCurrency() returns String
.setCurrency(amount.getCurrency())
//getContent() returns BigDecimal
.setNumber(amount.getContent())
.create();

单元测试时出现异常:

javax.money.MonetaryException: No MonetaryAmountsSingletonSpi loaded.

at javax.money.Monetary.lambda$getDefaultAmountFactory$13(Monetary.java:291)

最佳答案

JavaMoney 被分成单独的 API 和实现包,但您只将 API 添加到 POM。您还需要一个实现,例如引用实现:

<dependency>
<groupId>org.javamoney</groupId>
<artifactId>moneta</artifactId>
<version>1.2.1</version>
<type>pom</type>
</dependency>

关于java-money - 没有加载 MonetaryAmountsSingletonSpi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51043337/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com