我面临一个问题,Wiremock 说我的 URL 不匹配,即使它们相同。显然我错过了一些东西。我究竟做错了什么?
WireMock.stubFor(WireMock.get(WireMock.urlPathEqualTo("/test/url?bookingCode=XYZ123&lastName=TEST"))
.willReturn(WireMock.aResponse()
.withStatus(200))
)
Run Code Online (Sandbox Code Playgroud)
下面是控制台日志。
-----------------------------------------------------------------------------------------------------------------------
| Closest stub | Request |
-----------------------------------------------------------------------------------------------------------------------
|
GET | GET
/test/url?bookingCode=XYZ123&lastName=TEST | /test/url?bookingCode=XYZ123&lastName=TEST <<<<< URL does not match
|
|
-----------------------------------------------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
是因为我没有在匹配器中包含标题吗?
如果是,如何避免匹配标题?无论我发送什么标头,我都希望得到响应。
我正在尝试从 java 8 更新到 OpenJdk 11。当我从终端执行 mvn install 时,构建工作正常。但 (mac) intelliJ mvn install 失败
下面是启动命令
/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/bin/java -Dmaven.multiModuleProjectDirectory=/Users/myhome/Documents/WORKSPACES/something/develop“-Dmaven.home=/Applications/IntelliJ IDEA .app/Contents/plugins/maven/lib/maven3""-Dclassworlds.conf=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf"-Didea.launcher.port= 53262“-Didea.launcher.bin.path=/Applications/IntelliJ IDEA.app/Contents/bin”-Dfile.encoding=UTF-8 -classpath“/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/ maven3/boot/plexus-classworlds-2.5.2.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMainV2 org.codehaus.classworlds.Launcher -Didea .version=2018.2.6 -s /Users/myhome/Documents/config/maven/apache-maven-3.6.0/conf/settings.xml -Dmaven.repo.local=/Users/myhome/Documents/config/maven/回购安装
以下是错误行示例
[错误] /Users/myhome/Documents/WORKSPACES/something/SomeClass.java:[7,33] 无法访问 org.springframework.kafka.support
[错误] 未找到 zip END 标头
有什么解决办法吗?(已经将平台设置中的SDK更新为OpenJdk11,Maven>Runner正在使用OpenJdk11,Java编译器更新为11。
] 2
我知道我们有@org.springframework.context.annotation.ComponentScans和@org.springframework.context.annotation.ComponentScan。
@ComponentScans()?@ComponentScans()不同@ComponentScan({"com.org.abc", "com.org.xyz"})kotlin 的替代品是什么
@Autowired(required=false)
private DependencyC dependencyC;
Run Code Online (Sandbox Code Playgroud)
和
private Optional<HelloService> optionalHelloService;
public HelloController(Optional<HelloService> helloService) {
this.optionalHelloService = helloService;
}
Run Code Online (Sandbox Code Playgroud) 从 spring-docs,我可以看到
MANUAL - 消息侦听器负责确认()确认;之后,应用与 BATCH 相同的语义。
MANUAL_IMMEDIATE - 当侦听器调用 Acknowledgment.acknowledge() 方法时立即提交偏移量。
但是如果侦听器提交偏移量到底有什么区别。为MANUAL模式做了哪些额外的步骤
试图弄清楚我是否可以使用spring-kafka和spring-kafka-test为@KafkaListener编写单元测试。
我的侦听器类。
public class MyKafkaListener {
@Autowired
private MyMessageProcessor myMessageProcessor;
@KafkaListener(topics = "${kafka.topic.01}", groupId = "SF.CLIENT", clientIdPrefix = "SF.01", containerFactory = "myMessageListenerContainerFactory")
public void myMessageListener(MyMessage message) {
myMessageProcessor.process(message);
log.info("MyMessage processed");
}}
Run Code Online (Sandbox Code Playgroud)
我的测试班:
@RunWith(SpringRunner.class)
@DirtiesContext
@EmbeddedKafka(partitions = 1, topics = {"I1.Topic.json.001"})
@ContextConfiguration(classes = {TestKafkaConfig.class})
public class MyMessageConsumersTest {
@Autowired
private MyMessageProcessor myMessageProcessor;
@Value("${kafka.topic.01}")
private String TOPIC_01;
@Autowired
private KafkaTemplate<String, MyMessage> messageProducer;
@Test
public void testSalesforceMessageListner() {
MyMessageConsumers myMessageConsumers = new MyMessageConsumers(mockService);
messageProducer.send(TOPIC_01, "MessageID", new MyMessage());
verify(myMessageProcessor, times(1)).process(any(MyMessage.class));
}}
Run Code Online (Sandbox Code Playgroud)
我的测试配置类:
@Configuration
@EnableKafka …Run Code Online (Sandbox Code Playgroud) 我想测试一个修复,其中SimpleDateFormat用作静态类变量.我得到了
以前我的代码是
public class Abc{
private static SimpleDateFormat dateformatter;
public static String method1(final Calendar calendar) {
String thePattern = "ddMMM";
dateformatter = new SimpleDateFormat(thePattern, Locale.US);
sPars = dateformatter.format(calendar.getTime());
//Something
}
public static String method2(final Calendar calendar) {
String thePattern = "ddMMyyyy";
dateformatter = new SimpleDateFormat(thePattern, Locale.US);
sPars = dateformatter.format(calendar.getTime());
//Something
}
}
Run Code Online (Sandbox Code Playgroud)
对于这个,我得到了以下异常
java.lang.ArrayIndexOutOfBoundsException: 965
at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:454)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2333)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2248)
at java.util.Calendar.setTimeInMillis(Calendar.java:1140)
at java.util.Calendar.setTime(Calendar.java:1106)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:955)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:948)
at java.text.DateFormat.format(DateFormat.java:336)
Run Code Online (Sandbox Code Playgroud)
现在我已将其更改为:
public class Abc{
public static String method1(final Calendar …Run Code Online (Sandbox Code Playgroud)