Basically, you would't need almostwould want to avoid any Spring Boot dependencies (initially), except contextstarter that brings up a container/server.
Initially, I do use this starterhave only these two dependencies: com.github.tomakehurst:wiremock-jre8:2.31.0
and org.springframework.boot:spring-boot-starter-json
.
Then state Optionally, confirm you don't want to run any Web applicationserver(s): spring.main.web-application-type: none
. Declare
Finally, declare a WireMockServer
beanconfig file to setup WireMock:
@Configuration
@AllArgsConstructor
@EnableConfigurationProperties(WireMockConfig.ApplicationProps.class)
public class WireMockConfig {
private final ApplicationProps props;
@Bean
public WireMockServer mockServer() {
final var configurationreturn =new WireMockServer(WireMockConfiguration.options().port(props.wiremock.port8081));
return new WireMockServer(configuration);}
}
...and a listener to start thatthe server, either on mockServer()
or using some other way.:
@Component
@AllArgsConstructor
public class ApplicationListener {
private final WireMockServer server;
@EventListener
public void onApplicationEvent(final ApplicationReadyEvent event) {
server.start();
}
}