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 spring2hello; import com.app.config.App2Config; import com.app.config.AppConfig; import com.app.model.daoRepo.*; import com.app.model.daoservice.OrderService; import com.app.model.jpaservice.JpaService; import com.app.model.jpaservice.JpaServiceImpl; import com.app.model.entity.User; import java.util.List; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import javax.sql.DataSource; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.apache.commons.dbcp.BasicDataSource; import org.apache.commons.dbcp.BasicDataSourceFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.boot.SpringApplication; import org.springframework.context.annotation.AnnotationConfigApplicationContext; //<editor-fold defaultstate="collapsed" desc="comment"> //</editor-fold> /** * * @author User */ public class MainClass { /* @Autowired JpaService jpaServis; */ public static void maina(String[] args) throws BeansException { // throws BeansException { //@Autowired //OrderService os; //NewMain nm = new NewMain();5 //SpringApplication.run(AppConfig.class); /* ApplicationContext context = (ApplicationContext) new ClassPathXmlApplicationContext("beans.xml"); */ //SpringApplication.run(App2Config.class); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); //HelloWorld helloWorld = (HelloWorld) context.getBean("helloWorldBean"); /* Beana b = (Beana) context.getBean("mojaBeana"); User u = (User) context.getBean("userBeana"); Properties ap = (Properties) context.getBean("myProp"); BasicDataSourceFactory f = (BasicDataSourceFactory) context.getBean("myDSfact"); Properties p = new Properties(); /*/ //OrderDAO orderDAO = (OrderDAO)context.getBean(OrderDAO.class); //OrderDAO repo = (OrderDAO)context.getBean("myRepo"); //repo.createDbTable(); //OrderService servis = (OrderService)context.getBean(OrderService.class); OrderService servis = (OrderService) context.getBean(OrderService.class); List<? extends Object> lista = servis.findAll("USER"); for (Object us : lista) { System.out.println("useR " + ((User) us).getId() + " " + ((User) us).getFirst_name() + " : " + ((User) us).getLast_name()); } /* p.setProperty("driverClassName", "com.mysql.jdbc.Driver"); p.setProperty("url", "jdbc:mysql://localhost/iivos_ap"); p.setProperty("username", "root"); p.setProperty("password", ""); /*/ //JdbcTemplate t = (JdbcTemplate) context.getBean("myTempl"); /* try { BasicDataSource c = (BasicDataSource)BasicDataSourceFactory.createDataSource(p); System.out.println(c.toString()); } catch (Exception ex) { Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex); } /*/ //SomeUsers usrs = new SomeUsers(); //Beana ab = new Beana(); /* System.out.println(b.saySomething()); System.out.println(u.getFirst_name()); System.out.println(f.toString()); System.out.println(p.toString()); System.out.println(ap.toString()); System.out.println(ab.toString()); System.out.println(t.toString()); */ } }