skynetcap / solanaj

Solana RPC client written in Java
MIT License
91 stars 47 forks source link

How do I inject rpcClient into springboot #55

Open wudaowu opened 2 months ago

wudaowu commented 2 months ago

image image

skynetcap commented 2 months ago

Looks correctly defined to me. This is a Spring-related question. I'd see if your using component scanning or not to import the configuration files/beans. You may need an @Import tag added to your root config for this to work. Not sure your project structure. Again, this is not a SolanaJ problem, but I can assist a bit.

It's also possible that your properties file isn't being read correctly, and thus the RpcClient fails to instantiate.

wudaowu commented 2 months ago

I found the problem,OkHttpClient in RpcClient is a kotlin object, which cannot be automatically managed by springboot.This time a null pointer appears. The error seems to be that the initialization of the OkHttpClient object failed. All fields need to be assigned values. image image image image