Created
October 25, 2015 14:55
-
-
Save gregori/dba18eb4891a2cbfbcb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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