Hmz3192 opened a new issue #11917:
URL: https://github.com/apache/shardingsphere/issues/11917


   ## Version
   4.0.0
   
   ## Problem
   In the springboot framework, I need to connect to the database to query the 
required data in the custom sub database algorithm, but I can't get the 
instantiated service, applicationcontextservice and componentscan. I can ensure 
that the configuration is correct. It's normal to instantiate the service with 
spring annotation or spring context in other normal controllers, However, it 
cannot be instantiated in the custom sub database algorithm, and the 
acquisition is always null。
   
   How can I get the spring service in shardingalgorithm? Does shardingsphere 
have its own context? I have seen shardingcontent. Can I get the service 
through this? There is no relevant example for reference.
   ## Result
   
![image](https://user-images.githubusercontent.com/26765797/130184833-cccd589a-6cf5-45f6-8253-b68353a03599.png)
   The context can be instantiated normally when the container is 
initialized,as follow
   
![image](https://user-images.githubusercontent.com/26765797/130185024-81b605a3-14ef-4cbd-8862-46b963802284.png)
   When I enter the sub database algorithm, neither the context nor the spring 
annotation can get the service, which are all null
   
![image](https://user-images.githubusercontent.com/26765797/130185104-deb7973c-3edc-4688-8ab0-119d91dffc42.png)
   
![image](https://user-images.githubusercontent.com/26765797/130185127-e54dad9d-57c0-4fbc-9105-9aa27bb85fd7.png)
   
   
   
   
   
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to