我有如下的gradle测试任务:
public struct PortfolioModel : Decodable {
let symbolsRequested: Int
let symbolsReturned: Int
let data: [Portfolio]
enum CodingKeys: String, CodingKey {
case symbolsRequested = "symbols_requested"
case symbolsReturned = "symbols_returned"
case data = "data"
}
}
struct Portfolio: Codable {
let symbol, name, currency, price, priceOpen, dayHigh, dayLow: String
let the52_WeekHigh, the52_WeekLow, dayChange, changePct, closeYesterday, marketCap: String
let volume, volumeAvg, shares, stockExchangeLong, stockExchangeShort, timezone: String
let timezoneName, gmtOffset, lastTradeTime: String
enum CodingKeys: String, CodingKey {
case symbol = "symbol", name = "name", currency = "currency"
case price = "price", priceOpen = "price_open", dayHigh = "day_high"
case dayLow = "day_low", the52_WeekHigh = "52_week_high", the52_WeekLow = "52_week_low"
case dayChange = "day_change", changePct = "change_pct", closeYesterday = "close_yesterday"
case marketCap = "market_cap", volume = "volume", volumeAvg = "volume_avg", shares = "shares"
case stockExchangeLong = "stock_exchange_long", stockExchangeShort = "stock_exchange_short"
case timezone = "timezone", timezoneName = "timezone_name", gmtOffset = "gmt_offset", lastTradeTime = "last_trade_time"
}
}
但是当我运行gradle build时,它给我一个错误
Gradle套件> Gradle测试> com.myproject.test.FirstTest> startCassandra失败 java.lang.NoSuchFieldError:DIGIT 在org.apache.cassandra.io.sstable.format.SSTableFormat $ Type。(SSTableFormat.java:58) 在org.apache.cassandra.io.sstable.format.SSTableFormat $ Type。(SSTableFormat.java:46) 在org.apache.cassandra.config.DatabaseDescriptor。(DatabaseDescriptor.java:87)
但是如果我通过右键单击它-> Run As-> TestNG将测试类作为TestNG测试运行,则它运行良好。
什么可能导致差异?我一直在试图找出我做错了什么,但似乎只有在我尝试通过Gradle进行测试时,它才失败。
答案 0 :(得分:0)
我认为您的错误与Apache的以下JIRA有关
答案 1 :(得分:0)
Datastax提供了如下所示的带阴影的Guava库,我删除了实际的Guava库,并在下面添加了它,对我来说很好用。
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-shaded-guava</artifactId>
<version>25.1-jre</version>
</dependency>