asyncapi / java-spring-template

Java Spring template for the AsyncAPI Generator
Apache License 2.0
67 stars 54 forks source link

[BUG] SpringBoot3: Use jackson-jakarta-rs-json-provider instead of jackson-jaxrs-json-provider #416

Open corentin-pasquier opened 1 month ago

corentin-pasquier commented 1 month ago

Describe the bug.

We were trying to use the library to generate code; this code deployed as as jar to our repository and imported in a Spring Boot 3 project. We have an error when starting our Spring Boot 3 project and we find out that this dependency is causing problem:

<dependency>
    <groupId>com.fasterxml.jackson.jaxrs</groupId>
    <artifactId>jackson-jaxrs-json-provider</artifactId>
    <scope>compile</scope>
</dependency>

This dependency is using old javax, this dependency should be replaced (when using springBoot3 and not springBoot2) by:

<dependency>
    <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
    <artifactId>jackson-jakarta-rs-json-provider</artifactId>
    <scope>compile</scope>
</dependency>

Expected behavior

Use Jakarta compliant dependency for a Spring Boot 3 generated code.

<dependency>
    <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
    <artifactId>jackson-jakarta-rs-json-provider</artifactId>
    <scope>compile</scope>
</dependency>

Screenshots

image

How to Reproduce

  1. Generate a Spring Boot 3 project Follow the link with every needed dependencies to reproduce Spring Initializr

  2. Generate code with spring template

    $ node --version
    v18.14.2
    $ npm i -g @asyncapi/cli
    $ npm i -g @asyncapi/java-spring-template
    $ wget https://raw.githubusercontent.com/ab510/asyncapi/refs/heads/master/examples/2.0.0/streetlights.yml
    $ asyncapi generate fromTemplate streetlights.yml @asyncapi/java-spring-template --param maven=true --output generated-
  3. Install package to your device maven repository Before I had to change StreetLightId equals function so it returns true (there is a compilation error). image

$ cd generated-code
$ mvn install -DskipTests
  1. Then add the dependency to your Spring Boot 3 project:

    <dependencies>
        <dependency>
            <groupId>com.asyncapi</groupId>
            <artifactId>untitled</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
  2. Start your application image

  3. Change the dependency to the jakarta one, it works

🥦 Browser

Google Chrome

👀 Have you checked for similar open issues?

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

github-actions[bot] commented 1 month ago

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.