Closed pdkproitf closed 1 month ago
I tried this solution but it still doesn't work.
Do you invoke the constructor of GrpcClientService somewhere or do you let Spring handle that?
hi @ST-DDT thank for your response. i do invoke it when start the application
@SpringBootApplication
@Import(GrpcClientAutoConfiguration.class)
public class GrpcClientApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(GrpcClientApplication.class, args);
System.out.println("GrpcClientApplication started successfully.");
}
@Override
public void run(String... args) throws Exception {
System.out.println("GrpcClientApplication running.");
GrpcClientService grpcClientService = new GrpcClientService();
System.out.println(grpcClientService.sendMessage("John"));
}
}
GrpcClientService grpcClientService = new GrpcClientService();
That line is the issue. Since you create the bean yourself, spring cannot inject anything into it.
You have to use appContext.getBean(GrpcClientService.class)
instead.
I see, it works for me. (Spring Boot is still new to me) Thank you so much @ST-DDT
The context I'm implementing a gRPC client using 'net.devh:grpc-client-spring-boot-starter:3.0.0.RELEASE'. However, I encountered an error: @GrpcClient is null. I saw some similar issues reported, but they were using an older version, and the workaround solution links are no longer available, so I'm unable to find the solution
The bug
Code:
applicaiton.yml
Exception:
The application's environment
Which versions do you use?
Additional context