Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hendrixroa/e22f860a6334b1924728493f40e5a8a8 to your computer and use it in GitHub Desktop.
Save hendrixroa/e22f860a6334b1924728493f40e5a8a8 to your computer and use it in GitHub Desktop.
Sample in spring boot to display and use a timer
package com.blog.noiselesstech;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.concurrent.TimeUnit;
@SpringBootApplication
public class NoiselesstechApplication implements CommandLineRunner {
private static Logger LOG = LoggerFactory
.getLogger(NoiselesstechApplication.class);
public static void main(String[] args) {
SpringApplication.run(NoiselesstechApplication.class, args);
}
@Override
public void run(String... args) throws InterruptedException {
LOG.info("Running NoiselessTech Cron for a few seconds");
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException exception) {
throw new InterruptedException("Interrupt error");
}
LOG.info("NoiselessTech APP Finished");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment