Skip to content

Instantly share code, notes, and snippets.

@gregori
Created October 25, 2015 14:55
Show Gist options
  • Save gregori/dba18eb4891a2cbfbcb4 to your computer and use it in GitHub Desktop.
Save gregori/dba18eb4891a2cbfbcb4 to your computer and use it in GitHub Desktop.
@SpringBootApplication
public class Application implements CommandLineRunner {
// Objeto para escrever no console de log
private final Logger logger = LoggerFactory.getLogger(Application.class);
// Injeção, instância automática do objeto
@Autowired
private DummyService dummyService;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... strings) throws Exception {
String foo = dummyService.foo();
logger.info("DummyService retornou {}", foo);
}
}
@Service
public class DummyService {
private final Logger logger = LoggerFactory.getLogger(DummyService.class);
public String foo() {
logger.debug("Foo foi chamado");
return "bar";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment