OiO.lk English java Adding a new package broke my Spring Boot Application
java

Adding a new package broke my Spring Boot Application


Good morning. I’m getting troubles since I have added a new package in my spring boot application containing Mapstructs’ mappers. Looks like the field

@Autowired

private UtenteMapper utenteMapper;

is not being populated in my Service component. The Spring boot main class, PaniECumpanagghiuApplicationConfiguration, is quite essential, (it contains only the @SpringBootApplicationAnnotation annotation), but I’ve tried previously to add a @ComponentScan.

@SpringBootApplication

@ComponentScan("PaniECumpanagghiu.PaniECumpanagghiu.Mappers")

In this way the functionality is being recovered, but the @Controller is not fired (when I invoke my API the server retrieves 404). I tried also to add all the packages into the annotation @ComponentScan, like this

@ComponentScan("PaniECumpanagghiu.PaniECumpanagghiu.Mappers","PaniECumpanagghiu.PaniECumpanagghiu.controller",...)

In this way neither the former object, UtenteMapper, is populated anymore (same behavior than the case without @ComponentScan annotation).

If I comment all references to the new package, and I simplify the API in order to return only a String ("Ciao"), the controller is fired. This is my tree directory

Work tree

I have described everything in the previous section



You need to sign in to view this answers

Exit mobile version