Micronaut dependency inject not working with picocli feature

129
July 21, 2019, at 5:00 PM

I created a micronaut project using below command

mn create-cli-app micronaut-cli

With in the project I created a @Singleton class and I am injecting it into my Command class but inject is not working because object is always null.

My Singleton class:

@Singleton
public class ConverterService {
    public String service(){return "good service";}
}

My Command class:

@Command(name = "mini-java-util", description = "...",
    mixinStandardHelpOptions = true)
public class MiniJavaUtilCommand implements Runnable {
    @Inject ConverterService converterService;
    @Option(names = {"-v", "--verbose"}, description = "...")
boolean verbose;
    public static void main(String[] args) throws Exception {
        PicocliRunner.run(MiniJavaUtilCommand.class, args);
    }
    public void run() {
        // business logic here
        if (verbose) {
            System.out.println("converterService :" + converterService);
        }
    }
}

When I run this class I am getting:

converterService :null

Please help me why dependency injection is not working.

READ ALSO
Web service validation fails after run on Tomcat

Web service validation fails after run on Tomcat

I am new to Java and RESTful web services in JavaI developed a web service following this tutorial: https://www

116
how to get last downloaded file name from chrome download list [i.e. chrome://downloads] using java?

how to get last downloaded file name from chrome download list [i.e. chrome://downloads] using java?

I want to get the last downloaded file name to read it from javaI am working with selenium and need to get the last downloaded file name from chrome download list or from my download directory

87
Using Python Libraries or Codes in My Java Application [duplicate]

Using Python Libraries or Codes in My Java Application [duplicate]

This question already has an answer here:

121
Instatiate new ArrayQueue to remain Generic

Instatiate new ArrayQueue to remain Generic

I need to create a second ArrayQueue of the same type that is passed in, so I can items in the QueueI cannot instantiate the second ArrayQueue unless I make it of a specific class which defeats the purpose of the generic and fails the tests when the test switches...

123