I'm taking a Spring framework course and I'm having a lot of trouble with this as it seems to be correct from what the course is showing me. I keep getting a exception saying
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.in28minutes.spring.learnspringframework.GameRunner' available"
Main class
@SpringBootApplication
public class LearnSpringFrameworkApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context;
context = SpringApplication.run(LearnSpringFrameworkApplication.class, args);
//MarioGame game = new MarioGame();
//PacmanGame pac = new PacmanGame();
//GameRunner runner2 = new GameRunner(game);
GameRunner runner = context.getBean(GameRunner.class);
runner.run();
}
}
Game Runner class, the one that is considered "not a qualifying bean"
@Component
public class GameRunner {
@Autowired
private GamingConsole game;
public GameRunner(GamingConsole game) {
this.game = game;
}
public void run() {
game.up();
game.down();
game.left();
game.right();
}
}
Gaming Console Interface
@Component
public interface GamingConsole {
void up();
void down();
void left();
void right();
}