Ao tentar chamar o método "OpenAiService::createCompletion" é gerado o seguinte log:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.fasterxml.jackson.databind.ObjectWriter.writeValueAsBytes(ObjectWriter.java:1172)
The following method did not exist:
'void com.fasterxml.jackson.core.util.BufferRecycler.releaseToPool()'
The calling method's class, com.fasterxml.jackson.databind.ObjectWriter, was loaded from the following location:
jar:file:/C:/Users/Pedro%20Gon%c3%a7alves/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.17.0/jackson-databind-2.17.0.jar!/com/fasterxml/jackson/databind/ObjectWriter.class
The called method's class, com.fasterxml.jackson.core.util.BufferRecycler, is available from the following locations:
jar:file:/C:/Users/Pedro%20Gon%c3%a7alves/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.15.4/jackson-core-2.15.4.jar!/com/fasterxml/jackson/core/util/BufferRecycler.class
The called method's class hierarchy was loaded from the following locations:
com.fasterxml.jackson.core.util.BufferRecycler: file:/C:/Users/Pedro%20Gon%c3%a7alves/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.15.4/jackson-core-2.15.4.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.fasterxml.jackson.databind.ObjectWriter and com.fasterxml.jackson.core.util.BufferRecycler
Exception in thread "main" java.lang.IllegalStateException: java.lang.NoSuchMethodError: 'void com.fasterxml.jackson.core.util.BufferRecycler.releaseToPool()'
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:825)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:344)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
at br.com.alura.screenmatch.ScreenmatchApplication.main(ScreenmatchApplication.java:12)
Caused by: java.lang.NoSuchMethodError: 'void com.fasterxml.jackson.core.util.BufferRecycler.releaseToPool()'
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsBytes(ObjectWriter.java:1172)
...
Process finished with exit code 1
Me parece que o problema acontece por uma incompatibilidade de versões da dependencia Jackson. Abaixo se encontra o arquivo "pom.xml":
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>br.com.alura</groupId>
<artifactId>screenmatch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>screenmatch</name>
<description>Projeto Spring sem Web</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>com.theokanning.openai-gpt3-java</groupId>
<artifactId>service</artifactId>
<version>0.18.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Como posso corrigir este problema?