use of com.tvd12.example.spring_boot.service.BookService in project java-examples by tvd12.
the class MyApplicationStartup method main.
public static void main(String[] args) {
ApplicationContext appContext = SpringApplication.run(MyApplicationStartup.class, args);
BookService bookService = appContext.getBean(BookService.class);
bookService.saveBook(new Book(1, "youngmonkeys.org"));
}
use of com.tvd12.example.spring_boot.service.BookService in project java-examples by tvd12.
the class ApplicationContextExample method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.scan("com.tvd12.example.spring_core.config");
context.scan("com.tvd12.example.spring_core.repo");
context.scan("com.tvd12.example.spring_core.service");
context.refresh();
BookService bookService = context.getBean(BookService.class);
System.out.println(bookService.getBookById(1));
Environment environment = context.getEnvironment();
String world = environment.getProperty("hello");
System.out.println(world);
}
Aggregations