Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.com.gumga.academia.modulo2.aplicacao; import br.com.gumga.academia.entidade.Cliente; import br.com.gumga.academia.modulo2.aplicacao.servico2.ClienteService2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.stereotype.Component; @Component public class MainService2 { @Autowired private ClienteService2 clienteService; public MainService2() { } public void run() { Cliente cliente = new Cliente("Gumga Cliente"); clienteService.salvar(cliente); clienteService.buscarTodos().forEach((cli) -> { System.out.println(cli); }); } public static void main(String[] args) { ApplicationContext ctx = new AnnotationConfigApplicationContext(Aplicacao.class); MainService2 ms = ctx.getBean(MainService2.class); ms.run(); } }