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; import br.com.gumga.academia.entidade.Cliente; import br.com.gumga.academia.service.ClienteService; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.stereotype.Component; /** * * @author wesley */ @Component public class MainService { @Autowired private ClienteService clienteService; public MainService() { } public void run() { Cliente cliente = new Cliente("Gumga Cliente"); clienteService.salvar(cliente); List<Cliente> list = clienteService.obterClientes(); for (Cliente c : list) { System.out.println(c); } } public static void main(String[] args) { ApplicationContext ctx = new AnnotationConfigApplicationContext(Aplicacao.class); MainService ms = ctx.getBean(MainService.class); ms.run(); } }