I was wondering what is the difference between creating a new class and injecting it with the @Autowired annotation and creating a class and take the object of this class and using its methods. Is there any techical reason(i.e. faster access etc)?
Service case:
@Service
public class AuthorService implements AuthorServiceInterface {
//some methods
}
Simple Class case:
public class AuthorService implements AuthorServiceInterface {
//some methods
}
If i want to call the first one in another class i have to write:
public Class myclass{
@Autowired
AuthorService authorservice;
}
In the second case i have to write:
public Class myclass{
AuthorService authorservice = new AuthorService():
}
Whats the difference between these two cases?