slim
slim

Reputation: 469

OptaPlanner - No beans of SolverManager and SolverManager types found in Spring Boot application

I've added optaplanner-spring-boot-starter dependency on a Spring Boot application but injected SolverManager and ScoreManager beans were not found on Intellij.

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method myBusinessBeanAPI in 
mypackage.MyRestResource required a bean 
of type 'org.optaplanner.core.api.solver.SolverManager' that could not be found.


Action:

Consider defining a bean of type 'org.optaplanner.core.api.solver.SolverManager' in your 
configuration.

How can I solve this problem ?

Upvotes: 0

Views: 375

Answers (1)

Abhinaba Chakraborty
Abhinaba Chakraborty

Reputation: 3671

In the documentation, it says In Quarkus and Spring Boot, the SolverManager instance is automatically injected in your code. Otherwise, build a SolverManager instance with the create(…​) method:

SolverConfig solverConfig = SolverConfig.createFromXmlResource(".../cloudBalancingSolverConfig.xml");
SolverManager<CloudBalance, UUID> solverManager = SolverManager.create(solverConfig, new SolverManagerConfig());

So probably you didnt import the dependency correctly. If you are using maven and using dependency management config:

<dependencies>
...
<dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-spring-boot-starter</artifactId>
</dependency>
...
</dependencies>
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.optaplanner</groupId>
                <artifactId>optaplanner-spring-boot-starter</artifactId>
                <version>7.38.0.Final</version>
            </dependency>
        </dependencies>
</dependencyManagement>

If you are using gradle:

compile 'org.optaplanner:optaplanner-spring-boot-starter:7.38.0.Final'

Upvotes: 1

Related Questions