micronaut-projects / micronaut-spring

A collection of utilities for Spring users of Micronaut
Apache License 2.0
164 stars 46 forks source link

Micronaut not picking up spring @RestController apis defined in 3rd party spring boot jar #597

Open subash89 opened 4 months ago

subash89 commented 4 months ago

Expected Behavior

I use @Import(org.myapp.class) in my Micronaut-spring app class. And expect it to pickup the XGreetingController defined in the 3rd party jar.

Actual Behaviour

Expect the api defined in 3rd party jar to be picked up and api should return 200ok response.

Steps To Reproduce

Two Projects springboot and micronautspring Zip springtomicronaut.zip

  1. Go to springboot and mvn clean install
  2. Go to micronautspring and mvn clean install
  3. The micronautspring project have a dependency of micronaut-projects/micronaut-core#1 springboot.
  4. Now start app inside micronautspring by java -jar target/default-0.1.jar

Invoke APIs

  1. Invoke api directly defined in micronautspring app itelf. curl -v -X 'GET' 'http://localhost:8080/greeting' and gives 200OK.
  2. Invoke api defined in 3rd party jar springboot. curl -v -X 'GET' 'http://localhost:8080/hello' and gives 404.

Reference code. Refer zip file for complete examples.

Controller defined in Micronaut spring app and doing an @Import as follows.

@SpringBootApplication // <1>
@Import(org.myapp.XGreetingController.class)
public class Application {

    public static void main(String... args) {
        Micronaut.run(Application.class);
    }
}

Question is how to get micronautspring app to pickup/find the controller defined in the springboot app jar ?

Environment Information

JDK 21

Example Application

No response

Version

4.4.3