I've got a problem with @Autowiring being null. I am looking for advice how to model it the spring-boot-way.
My Soap-Services get really big using lots of Repository classes. This gives me a large list of @Autowired already. Now when I want to call a helper-class like HeaderValidator.class I can't instantiate and call it like a POJO. This because everything annotated @Autowiring in my HeaderValidator is null. I can make it work when I add @Autowired at line (1) and remove the content of (2) in SoapServiceImpl. But this will end in a huge list of @Autowired annotated fields and this looks ugly. I want to prevent this even it works for now.
This Article mentions the @Configurable with AspectJ. But the Article is from 2013 and Spring-Boot has developed since. I tried the @Configurable solution but it didn't work in my case.
How can I inform my SpringBoot-Application of a class copy? Is the @Configurable-way still the only one? Or did I simply model the application wrong?
Application.class:
@SpringBootApplication
public class Application {
private static ApplicationContext ctx;
public static void main(String... args) {
ctx = SpringApplication.run(Application.class, args);
publishSoapServices();
}
SoapService.class (gets published when calling publishSoapServices() in Application.class):
public class SoapServiceImpl implements SoapService {
@Autowired
ProjectRepository projectRepo;
(1) "@Autowired"
HeaderValidator headerValidator;
@Override
public EventReport send(@WebParam(name = "header") HeaderType headerType,
@WebParam(name = "content") ContentType contentType) {
return storeServiceData(headerType, messageType);
}
private EventReport storeServiceData(HeaderType headerType, ContentType contentType) {
projectRepo.save(contentType);
(2) "HeaderValidator headerValidator= new HeaderValidator()"
return headerValidator.validate(headerType);
}
My problem class:
@Service
public class HeaderValidator {
@Autowired
ValidFieldsRepository validFieldsRepo; //<-- always null!