package com.github.forax.pro.example.springboot;

import java.util.Set;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
	  // spring boot component scan fails if modules are linked with jlink
	  // i.e. are not loaded by the application classloader 
		//SpringApplication.run(DemoApplication.class, args);
	  
	  // explicitly register the REST controller
	  SpringApplication app = new SpringApplication(DemoApplication.class);
	  app.setSources(Set.of(ModuleController.class.getName()));
	  app.run(args);
	}
}

package com.github.forax.pro.example.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@EnableAutoConfiguration
@Import({ ModuleController.class })   // spring boot component scan fails if modules are linked with jlink
public class DemoApplication {
	public static void main(String[] args) {
	  SpringApplication.run(DemoApplication.class, args);
	}
}

use @Import instead of the programmatic API to specify the REST controller