Can someone tell me please what I'm doing wrong, I'm trying to develop a little application but I just simply can't Autowire
a class in the controller, I have been researching and I Know that for Autowire
works, my class must be in a child package of my @SpringBootApplication
annotation, or I should specify in @ComponentScan
annotation the package of my class, but no matters what I do I still getting the same error:
This is my project structure:
package net.spring.auditoria;
import org.springframework.boot.SpringApplication;T
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AuditoriaApplication {
public static void main(String[] args) {
SpringApplication.run(AuditoriaApplication.class, args);
}
}
Controller:
package net.spring.auditoria.bll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class AuditoriaController {
@Autowired
private AuditoriaManagement am;
private final Logger LOGGER = LoggerFactory.getLogger(AuditoriaController.class);
@GetMapping("/auditar")
public String auditar() {
LOGGER.info("auditar()");
return "main";
}
}