I was trying to autowire an object in my class. No errors or exceptions were thrown, but if I call a method of that, it just won't work. What did I miss here?

This is how I autowire the object:

```
    @Autowired
    RetryOnException retry;

    public static void main(String[] args) {
        SpringApplication.run(CimsMigrationSftp100Application.class, args);
    }

    @Override
    public void run(String... args) throws Exception {

        while(retry.shouldRetry()) {
           // More codes here and below
        }

```

If I use `RetryOnException retry = new RetryOnException();`, it will work, and I can jump into the while loop. What is the difference between dependency injection and creating an object manually?

Below is `RetryOnException()`:

```
import static package.PAUSE_MS;
import static package.POST_MAX_RETRIES;
@Component
public class RetryOnException {

    private int numberOfRetries;
    private int numberOfTriesLeft;
    private long timeToWait;

    public RetryOnException() {
        this(POST_MAX_RETRIES, PAUSE_MS);
    }

    public RetryOnException(int numberOfRetries,
            long timeToWait) {
        this.numberOfRetries = numberOfRetries;
        numberOfTriesLeft = numberOfRetries;
        this.timeToWait = timeToWait;
    }

    /**
     * @return true if there are tries left
     */
    public boolean shouldRetry() {
        return numberOfTriesLeft > 0;
    }

    public void errorOccured() throws Exception {
        numberOfTriesLeft--;
        if (!shouldRetry()) {
            throw new Exception("Retry Failed: Total " + numberOfRetries
                    + " attempts made at interval " + getTimeToWait()
                    + "ms");
        }
        waitUntilNextTry();
    }

    public long getTimeToWait() {
        return timeToWait;
    }

    private void waitUntilNextTry() {
        try {
            Thread.sleep(getTimeToWait());
        } catch (InterruptedException ignored) {
        }
    }

}

```