Reputation: 23
I have an application with Optaplanner + Spring Boot, which solves VRP problem. One of the needs for solving this problem is to know the distances between two points. I do this through a separate class that makes the http request. I tried to inject a bean of this class through the @Autowired annotation, but the bean is not injected. Therefore, the question is whether it is possible to inject bean into the ConstrainProvider, since I don’t want to drag this dependency into the DAO layer
Upvotes: 2
Views: 175
Reputation: 1029
The ConstraintProvider
is not even instantiated as a bean in the Spring context, so you cannot inject anything into it.
Important to note, that making any HTTP requests from the constraints in the ConstraintProvider
will kill the performance.
If possible, try incorporating the distance matrix into your domain model and initialize it before solving.
Upvotes: 3