我正在尝试将json请求的Retrofit库添加到我的应用程序中.我得到一个非常简单但令人讨厌的错误.
当我执行此方法时:
@GET("/Server/ports/{portCode}")
@Headers({
"Content-Type: application/json",
"Accept-Language: en"
})
void listArrivalPorts(
@Path("portCode") String portCode,
Callback<PGSArrivalPortsResponse> callback
);
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Retrofit-Idle
java.lang.IllegalStateException: Method path "/Server/ports/{portCode}" does not contain {portCode}.
at retrofit.RestMethodInfo.parseParameters(RestMethodInfo.java:320)
at retrofit.RestMethodInfo.init(RestMethodInfo.java:90)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:202)
at retrofit.RestAdapter$RestHandler.access$300(RestAdapter.java:156)
at retrofit.RestAdapter$RestHandler$1.obtainResponse(RestAdapter.java:189)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:38)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at retrofit.Platform$Android$2$1.run(Platform.java:132)
at java.lang.Thread.run(Thread.java:1019)
Run Code Online (Sandbox Code Playgroud)
但当我删除这样的替换体,
@GET("/Server/ports/SOMETHING")
@Headers({
"Content-Type: application/json",
"Accept-Language: en"
})
void listArrivalPorts(
Callback<PGSArrivalPortsResponse> callback
);
Run Code Online (Sandbox Code Playgroud)
它工作正常.
此外,如果我添加参数@Path("portCode") String portCode我得到相同的错误.
为什么会这样?谢谢.
是否有可能在两个不同的应用程序之间使用共享元素转换?
android android-5.0-lollipop activity-transition shared-element-transition
我有yaml文件的片段:
field-name: my/data
Run Code Online (Sandbox Code Playgroud)
但我无法使用方法名称创建pojo setField-name
有什么方法可以解析此类Yaml文件?
这个问题已被多次询问,但我有一个问题,我认为这是一个独特的问题.
在这里.
我有一个表示两位数年份的字符串,即写入2016 I输入16
我要求将两位数年份转换为四位数年份,即16年成为2016年.
在经过一些问题和答案后,我做了以下发现
解决方案1
DateFormat sdfp = new SimpleDateFormat("dd.mm.yy");
Date d = sdfp.parse(input);
DateFormat sdff = new SimpleDateFormat("yyyy-MM-dd");
String date = sdff.format(d);
Run Code Online (Sandbox Code Playgroud)
这将是伟大的,但在我的情况下,我只有一年没有一个月或一天,我找不到一种方法来创建一年只有一个日期对象.
解决方案2
以上内容可以通过一个Calendar对象来解决,但它不允许输入年份字段的两位数年份.
编辑 忘了提到我不能使用Joda-Time,因为我正在使用Android平台,它会增加我的项目的大小只是为了这么小的用途
我有一个包含某些int字段的对象的集合.
例如.
public class Foo {
public int field;
}
Run Code Online (Sandbox Code Playgroud)
我想获得一个具有最接近某个值的元素(例如42).
是否有任何来自番石榴的方法来实现这样的事情?
我想status在构造函数中初始化字段而不是调用super.
class MyException : RuntimeException {
init {
val status: Status
}
constructor(status: Status) : super()
constructor(status: Status, cause: Throwable) : super(cause)
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现这一目标?
我想读File一下kotlin中的第一行(也是唯一一行).文件本身很大,所以我想使用内存高效的解决方案.
我想知道是否有更好的解决方案:
File("huge.txt").bufferedReader().readLine()
Run Code Online (Sandbox Code Playgroud) 我想启动 kafka 测试容器并获取它的引导服务器:
@SpringBootTest
@ContextConfiguration(classes = {TestConfig.class, MyApplication.class}, initializers = MyIntegrationTest.Initializer.class)
@Testcontainers
public class MyIntegrationTest {
@Container
private static final KafkaContainer KAFKA = new KafkaContainer();
static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(@NotNull ConfigurableApplicationContext configurableApplicationContext) {
TestPropertyValues values = TestPropertyValues.of(
"spring.kafka.consumer.bootstrap-servers=" + KAFKA.getBootstrapServers(),
"spring.producer.bootstrap-servers=" + KAFKA.getBootstrapServers()
);
values.applyTo(configurableApplicationContext);
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是我得到:
java.lang.IllegalStateException: You should start Kafka container first
at org.testcontainers.containers.KafkaContainer.getBootstrapServers(KafkaContainer.java:65) ~[kafka-1.12.2.jar:na]
Run Code Online (Sandbox Code Playgroud) 我有以下网址:
targetUrl := "http://google.com/foo/bar?a=1&b=2"
myUrl, err := url.Parse(targetUrl)
Run Code Online (Sandbox Code Playgroud)
我想知道如何bar从myUrl.Path?
我的持续时间字符串如下所示:
1:16.352
Run Code Online (Sandbox Code Playgroud)
其中1是分钟部分,16是秒部分,352是毫秒部分。
我想使用Duration.fromISOTime但我得到:
{
"reason": "unparsable",
"explanation": "the input \"1:16.352\" can't be parsed as ISO 8601"
}
Run Code Online (Sandbox Code Playgroud)
Luxon 有没有一种干净的方法来解析这样的持续时间?
java ×4
android ×3
kotlin ×2
annotations ×1
apache-kafka ×1
collections ×1
constructor ×1
duration ×1
field ×1
file ×1
go ×1
guava ×1
javascript ×1
json ×1
junit5 ×1
luxon ×1
path ×1
retrofit ×1
segment ×1
snakeyaml ×1
typescript ×1
uri ×1