Skip to content

@Autowire on Controller as Extension always Null #3

Description

@syifarahmat

How can you make the Controller as an Extension use @autowire, because the injector variable via @autowire that is in the Controller is always null

my api

public interface ControllerExt extends ExtensionPoint { }

my controller

@Slf4j
@Extension
@RestController
@RequestMapping("/plugin")
public class PluginController implements ControllerExt {

    @Autowired
    private ApplicationContext appContext; /* this always null */

    @Autowired
    private PluginService serv; /* this always null */

    @GetMapping("/abc/greetMVC")
    public ResponseEntity<String> greetMVC(){
        if (appContext != null) {
            log.info(appContext.getId());
            for (String a : appContext.getBeanDefinitionNames()) {
                log.info("appContext " + a);
            }
        } else {
            log.info("appContext null............");
        }
        log.info(serv.test("test"));
        return ResponseEntity.ok().body("An endpoint defined by annotation in plugin : @greetMVC");
    }
......

Thank's.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions