I am new to WireMock framework. My request is to run WireMock as a server that can accept stubs on a Spring Boot application. I tried to use the Spring Cloud Contract dependency but that only helps me in running the tests. Any direction or samples would be greatly helpful in this regard.
The main crux is to make the spring web-application-type: none in application.yml file. So that when the Spring Boot application is started from IDE it runs Wiremock on http port 8080 which internally runs on jetty server
Below is the appplication.yml file
spring: main: web-application-type: none application: name: App wiremock: server: files: classpath:/__files stubs: classpath:/mappings
Below is SpringBoot Application class
@SpringBootApplication
@Slf4j
@AutoConfigureWireMock
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
log.info("Starting Application");
SpringApplication.run(Application.class, args);
}
@Bean
public Options wireMockOptions() throws IOException {
final WireMockConfiguration options = WireMockSpring.options();
options.port(8080);
return options;
}
}
Please make sure you have these dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With