I have learnt that autowiring a bean is actually not a good practice. This is also mentioned in the spring document. I know that there are two types of bean configuration. One is by XML config, another is by java configuration class. If we want to use code to do bean configuration and not using @autowired, how can we do that? It seems like if using code, we will still need @autowired in order to inject the bean?
e.g. in the following, if we want to not using @Autowired, how can we do that? and what should be the best practice?
@Service
public class ClassA {
private ClassB classB;
@Autowired
public ClassA(ClassB classB) {
this.classB = classB;
}
}