0
Expensive
I’m having trouble injecting the classes by calling some methods using DWR with Hibernate.
Code:
@Controller
@Transactional
public class ManterArvoreClassificacaoController {
@Autowired
private ArvoreClassificacaoService acs;
@Autowired
private AreaArvoreClassificacaoService aacs;
@Autowired
private AreaService areaService;
@Autowired
private ArvoreSubClassificacaoService ascs;
public List<ArvoreClassificacao> listarArvoresArea(Area area) {
return acs.listarArvoresArea(area);
}
ArvoreClassificacaoService
is in fact a bean (is noted with@Service
)? 2) This class is in a package below the class that has the methodmain()
of its application? 3) The others Beans that controller work or are also null?– StatelessDev
@Statelessdev, the service is marked as <@Service>. My application has no Main() method, it is a web application.
– Kennedy Anderson
If you are using Spring Boot, you have a class annotated with at least,
@SpringBootApplication
and, within it, a methodmain()
. It refers to this class that I asked you about and that should be in a package above all others, so that Spring can properly scan your classes and create Beans. If this is not followed, yours Beans are not scanned, are not created and this may be the reason your injections are null.– StatelessDev
I’m using Spring MVC
– Kennedy Anderson