@Configurable annotation works fine, but you need to use @EnableSpringConfigured annotation in any configuration class in order to make it work. Read my answer in other stackoverflow post: spring autowiring not working from a non-spring managed class
Entity class should not contain any helpers, even if transient. For a clean design you need to separate concerns, so the entity should not be aware of your business logic. I cannot help you more since I don't know which is the goal of that helper, but here you have other alternatives:
ALTERNATIVE 1 (based on your description seems that helper is an stateful bean, so it is not candidate to be a @Service, which I personally think it should be)
@Controller
public MyController {
@RequestMapping(...)
public void processRequest() {
A a = new A();
...
Helper helper = new Helper(a); // CRepository is successfully autowired
}
}
@Configurable(autowire = Autowire.BY_TYPE)
public class Helper {
A a;
@Autowired
CRepository repo;
}
@Configuration
@EnableSpringConfigured
public Application {
...
}
ALTERNATIVE 2 (make your Helper class stateless so that spring is aware of your beans without the need of extra stuff like @Confgurable/@EnableSpringConfigured)
@Controller
public MyController {
@Autowired Helper helper; // CRepository is correctly autowired
@RequestMapping(...)
public void processRequest() {
A a = new A();
...
helper.doSomething(a);
}
}
@Service
public class Helper {
// A a; remove dependency to A to make it stateless
@Autowired
CRepository repo;
public Helper() {
}
public void doSomething(A a) {
...
repo.save(a);
}
}