I want to use WireMock with Java 8. Currently I m...
# help
r
I want to use WireMock with Java 8. Currently I managed to initialize it using:
Copy code
wireMockServer = new WireMockServer(WireMockConfiguration.options().port(8080));
        httpClient = HttpClients.createDefault();
        wireMockServer.start();
Is there a way to do it Spring way and use annotations instead? For example here https://wiremock.org/docs/solutions/spring-boot/ it talks about
@EnableWireMock
annotation. But when I try to add it to my code then with my dependency Intellij can't find where to import EnableWireMock.
Copy code
<dependency>
      <groupId>com.github.tomakehurst</groupId>
      <artifactId>wiremock-standalone</artifactId>
      <version>2.27.2</version>
      <scope>test</scope>
    </dependency>
I also tried this dependency:
Copy code
<dependency>
      <groupId>com.github.tomakehurst</groupId>
      <artifactId>wiremock-jre8</artifactId>
      <version>3.0.1</version>
      <type>pom</type>
      <scope>test</scope>
    </dependency>
But still no way to import @EnableWireMock annotation. Is there any way in java 8 not to initialize it in Java but rather use annotations like example on your home page?
l
This library might be worth looking into - https://github.com/maciejwalkowiak/wiremock-spring-boot
r
Tnx. Yes now I was able to import it but now I also get > java: cannot access com.github.tomakehurst.wiremock.http.MultiValue > bad class file: /C:/Users/rain.oksvort/.m2/repository/org/wiremock/wiremock-standalone/3.3.1/wiremock-standalone-3.3.1.jar!/com/github/tomakehurst/wiremock/http/MultiValue.class > class file has wrong version 55.0, should be 52.0 > Please remove or make sure it appears in the correct subdirectory of the classpath. That is not Java 8 compatible? That comes from line import com.github.tomakehurst.wiremock.http.MultiValue; in my code.
l
Did you use the latest version? Maybe a previous version supports java 8.
r
Yes, I used:
Copy code
<dependency>
    <groupId>com.maciejwalkowiak.spring</groupId>
    <artifactId>wiremock-spring-boot</artifactId>
    <version>2.1.2</version>
    <scope>test</scope>
</dependency>
Ok I found that 1.0.x versions even want java 17 for some reason.
l
I am not sure which version of that library is java 8 compatible. Might be worth contacting the author.
r
Thanks for your responses. Yes, that was compatible but it did not have @EnableWireMock. Only way there was to manually initialize it creating it using new keyword. I was wondering if there was java 8 version that has spring way of initializing things with annotations.
475 Views