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 org.bakujug.springrental; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * * @author Administrator */ public class Main { public static void main(String[] args) throws Exception { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml", "Spring-DataSource.xml"); CustomerRepository customerRepository = applicationContext.getBean("customerRepository", CustomerRepository.class); Customer customer = new Customer(); customer.setLastname("Ilkin"); customer.setFirstname("Abdullayev"); customer.setAge(23); customerRepository.save(customer); // Customer customer = customerRepository.getCustomerByName("Sunal"); // System.out.println(customer); // RentalService rentalService = (RentalService) applicationContext.getBean("rentalService"); // Rental rental = rentalService.rentACar("Ilkin", new Car("Fiesta"), getRentalBegin(), getRentalEnd()); // // System.out.println("Rental status: "+ rental.getCustomer()); } private static Date getRentalEnd() throws ParseException { return new SimpleDateFormat("dd/MM/yy").parse("29/12/2013"); } private static Date getRentalBegin() throws ParseException { return new SimpleDateFormat("dd/MM/yy").parse("22/12/2013"); } }