i'm finding issues with autowiring in my java application with spring-boot (1.5.17.RELEASE). In some class the autowire works and in others not. Each class that requires Autowired/Bean is signed as Component and into the application configuration, i made a basepackagescan:
@ComponentScan(basePackages = {"io.swagger", "io.swagger.api", "com.example.mypackage"},
excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = Swagger2SpringBoot.class)})
The class in wich the autowired doesn't work is that:
@Component
public class InputToDomain implements CustomConverter {
@Autowired
private ConnectionDAO connectionDAO;
public Domain convert(Object dest, Object source, Class<?> aClass, Class<?> aClass1) {
String cod_ = ((Request)source).getCod_();
return new Domain(connectionDAO.getAnag(cod_));
}
}
The ConnectionDao class is correctly autowired in another class marked equals as this. this is the ConnectionDao implementation:
@Repository
@Transactional
public class ConnectionDAO {
private final Logger log = LoggerFactory.getLogger(ConnectionDAO.class);
@Autowired
private SessionFactory sessionFactory;
private String table = "EXAMPLE_TABLE";
public List<Anagrafica> getAnag(String cod_){
SQLQuery sqlQuery = sessionFactory.getCurrentSession().createSQLQuery("select * from " + table +" where COD_ = :cod_");
sqlQuery.setParameter("cod_", cod_);
sqlQuery.addEntity(Anag.class);
return sqlQuery.list();
}
}
and is really similar to the class where autowired works. The class's package is included into the ComponentScan.
What should be the problem?
Thank you