├── tutorial_web_mvc ├── src │ └── main │ │ ├── webapp │ │ ├── index.jsp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ ├── views │ │ │ └── hello.jsp │ │ │ ├── web.xml │ │ │ └── springmvc-servlet.xml │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── webmvc │ │ └── HelloController.java ├── nb-configuration.xml └── pom.xml ├── tutorial_webmvc_theme ├── src │ └── main │ │ ├── resources │ │ └── themes │ │ │ ├── tema-claro.properties │ │ │ └── tema-oscuro.properties │ │ ├── webapp │ │ ├── css │ │ │ ├── claro.css │ │ │ └── oscuro.css │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── views │ │ │ └── home.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── controller │ │ └── ThemeController.java │ │ └── config │ │ └── WebAppInitializer.java └── nb-configuration.xml ├── tutorial_webmvc_noxml ├── src │ └── main │ │ ├── webapp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── views │ │ │ └── hello.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── webmvc │ │ └── HelloController.java │ │ └── config │ │ ├── MyWebApplicationInitializer.java │ │ └── AppConfig.java └── nb-configuration.xml ├── tutorial_webmvc_anotaciones ├── src │ └── main │ │ ├── webapp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ ├── views │ │ │ └── hello.jsp │ │ │ ├── springmvc-servlet.xml │ │ │ └── web.xml │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── webmvc │ │ └── HelloController.java │ │ └── config │ │ └── AppConfig.java └── nb-configuration.xml ├── tutorial_webmvc_controller ├── src │ └── main │ │ ├── webapp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── views │ │ │ ├── hello.jsp │ │ │ └── ventas.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── config │ │ ├── MyWebApplicationInitializer.java │ │ └── AppConfig.java │ │ └── controller │ │ └── VentasController.java └── nb-configuration.xml ├── tutorial_properties ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ ├── web │ │ │ └── index.html │ │ └── springXMLConfig.xml │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── introduccion │ │ ├── HelloService.java │ │ ├── HelloServiceImpl.java │ │ ├── Introduccion.java │ │ └── SpringConfiguration.java ├── nb-configuration.xml └── pom.xml ├── tutorial_spring_upload ├── src │ └── main │ │ ├── resources │ │ └── schema.sql │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── views │ │ │ └── image.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── config │ │ ├── WebAppInitializer.java │ │ ├── WebAppData.java │ │ └── WebAppConfig.java └── nb-configuration.xml ├── tutorial_webmvc_pdf_xls ├── src │ └── main │ │ ├── resources │ │ ├── views.properties │ │ └── log4j.properties │ │ ├── webapp │ │ └── META-INF │ │ │ └── context.xml │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── service │ │ ├── CustomerService.java │ │ └── CustomerServiceImpl.java │ │ ├── model │ │ └── Customer.java │ │ ├── WebAppInitializer.java │ │ ├── controller │ │ └── CustomerController.java │ │ ├── WebAppConfig.java │ │ └── view │ │ └── PdfView.java └── nb-configuration.xml ├── tutorial_webmvc_views ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── views │ │ │ ├── product.jsp │ │ │ └── productform.jsp │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ ├── service │ │ │ ├── CustomerService.java │ │ │ ├── CustomerServiceImpl.java │ │ │ ├── ProductService.java │ │ │ └── ProductServiceImpl.java │ │ │ ├── repository │ │ │ ├── CustomerRepository.java │ │ │ └── ProductRepository.java │ │ │ ├── model │ │ │ ├── Product.java │ │ │ └── Customer.java │ │ │ ├── WebAppInitializer.java │ │ │ └── WebAppConfig.java │ │ └── resources │ │ ├── schema.sql │ │ ├── log4j.properties │ │ └── data.sql └── nb-configuration.xml ├── tutorial_i18n ├── src │ └── main │ │ ├── resources │ │ ├── i18n │ │ │ ├── message_en.properties │ │ │ └── message_es.properties │ │ └── springXMLConfig.xml │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── introduccion │ │ ├── service │ │ ├── SaludaService.java │ │ └── SaludaServiceImpl.java │ │ ├── SpringConfiguration.java │ │ └── Introduccion.java ├── nb-configuration.xml └── pom.xml ├── tutorial_webmvc_json ├── src │ └── main │ │ ├── webapp │ │ └── META-INF │ │ │ └── context.xml │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ ├── service │ │ │ ├── CustomerService.java │ │ │ └── CustomerServiceImpl.java │ │ │ ├── WebAppInitializer.java │ │ │ ├── model │ │ │ └── Customer.java │ │ │ └── controller │ │ │ └── CustomerController.java │ │ └── resources │ │ └── log4j.properties └── nb-configuration.xml ├── tutorial_webmvc_report ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── views │ │ │ └── customer.jsp │ │ ├── resources │ │ ├── jasperreports │ │ │ └── customer_report.jasper │ │ └── log4j.properties │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── service │ │ └── CustomerService.java │ │ ├── model │ │ └── Customer.java │ │ ├── WebAppInitializer.java │ │ └── controller │ │ └── CustomerController.java └── nb-configuration.xml ├── tutorial_webmvc_resources ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ ├── public │ │ │ ├── images │ │ │ │ └── spring-by-pivotal.png │ │ │ └── css │ │ │ │ └── style.css │ │ └── WEB-INF │ │ │ └── views │ │ │ └── home.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── controller │ │ └── HomeController.java │ │ ├── WebAppInitializer.java │ │ └── WebAppConfig.java └── nb-configuration.xml ├── tutorial_webmvc_validacion ├── src │ └── main │ │ ├── resources │ │ ├── messages_en.properties │ │ └── messages_es.properties │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── views │ │ │ ├── userForm.jsp │ │ │ └── userReady.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── config │ │ ├── WebAppInitializer.java │ │ └── WebAppConfig.java │ │ └── controller │ │ └── UsuarioController.java └── nb-configuration.xml ├── tutorial_webmvc_HandlerMapping ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── views │ │ │ └── home.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── WebAppInitializer.java │ │ └── controller │ │ └── HomeController.java └── nb-configuration.xml ├── tutorial_webmvc_ViewResolver ├── src │ └── main │ │ ├── resources │ │ └── myviews.properties │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ ├── views │ │ │ ├── home.jsp │ │ │ └── index.jsp │ │ │ └── views.xml │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── controller │ │ └── HomeController.java │ │ └── config │ │ └── WebAppInitializer.java └── nb-configuration.xml ├── tutorial_webmvc_thymeleaf ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── templates │ │ │ ├── home.html │ │ │ └── userForm.html │ │ ├── resources │ │ ├── messages_en.properties │ │ └── messages_es.properties │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── model │ │ └── Tipo.java │ │ ├── config │ │ └── WebAppInitializer.java │ │ └── controller │ │ └── HomeController.java └── nb-configuration.xml ├── tutorial_webmvc_DynamicJasper ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── views │ │ │ └── customer.jsp │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ ├── service │ │ │ └── CustomerService.java │ │ │ ├── report │ │ │ ├── ReportGenerator.java │ │ │ └── DynamicReportView.java │ │ │ ├── model │ │ │ └── Customer.java │ │ │ ├── WebAppInitializer.java │ │ │ └── WebAppConfig.java │ │ └── resources │ │ └── log4j.properties └── nb-configuration.xml ├── tutorial_webmvc_thymeleaf_form ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ ├── views │ │ │ ├── userForm.jsp │ │ │ └── userReady.jsp │ │ │ └── templates │ │ │ └── userReady.html │ │ ├── resources │ │ ├── messages_es.properties │ │ └── messages_en.properties │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── config │ │ └── WebAppInitializer.java │ │ └── controller │ │ └── UsuarioController.java └── nb-configuration.xml ├── tutorial_webmvc_thymeleaf_i18n ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── templates │ │ │ └── userReady.html │ │ ├── resources │ │ ├── messages_en.properties │ │ └── messages_es.properties │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── config │ │ └── WebAppInitializer.java │ │ └── controller │ │ └── UsuarioController.java └── nb-configuration.xml ├── tutorial_beans ├── src │ └── main │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ └── introduccion │ │ │ ├── HelloService.java │ │ │ ├── ClientService.java │ │ │ ├── SpringConfiguration.java │ │ │ ├── Introduccion.java │ │ │ └── HelloServiceImpl.java │ │ └── resources │ │ └── springXMLConfig.xml ├── nb-configuration.xml └── pom.xml ├── tutorial_mvc_custom-validator └── tutorial_custom_validator │ ├── src │ └── main │ │ ├── webapp │ │ ├── META-INF │ │ │ └── context.xml │ │ └── WEB-INF │ │ │ └── views │ │ │ └── valid.jsp │ │ └── java │ │ └── carmelo │ │ └── spring │ │ ├── WebAppInitializer.java │ │ ├── WebAppConfig.java │ │ └── model │ │ └── Person.java │ └── nb-configuration.xml ├── tutorial_introduccion ├── src │ └── main │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ └── introduccion │ │ │ ├── HelloService.java │ │ │ ├── HelloServiceImpl.java │ │ │ ├── SpringConfiguration.java │ │ │ └── Introduccion.java │ │ └── resources │ │ └── springXMLConfig.xml ├── nb-configuration.xml └── pom.xml ├── tutorial_springboot-social-facebook └── src │ └── main │ ├── resources │ ├── application.properties │ └── templates │ │ ├── connect │ │ ├── facebookConnected.html │ │ └── facebookConnect.html │ │ └── hello.html │ └── java │ └── hello │ ├── Application.java │ └── HelloController.java ├── tutorial_springboot-social-twitter ├── src │ └── main │ │ ├── resources │ │ ├── application.properties │ │ └── templates │ │ │ ├── connect │ │ │ ├── twitterConnected.html │ │ │ └── twitterConnect.html │ │ │ └── tweetsPage.html │ │ └── java │ │ └── hello │ │ ├── Application.java │ │ └── TwitterController.java └── pom.xml ├── tutorial_autowiring ├── src │ └── main │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ └── autowiring │ │ │ ├── EmpleadoDao.java │ │ │ ├── EmpleadoService.java │ │ │ ├── EmpleadoDaoImpl.java │ │ │ ├── SpringJavaConfig.java │ │ │ ├── EmpleadoServiceImpl.java │ │ │ └── Autowiring.java │ │ └── resources │ │ └── springXMLConfig.xml ├── nb-configuration.xml └── pom.xml ├── tutorial_jdbc ├── src │ └── main │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ └── jdbc │ │ │ ├── dao │ │ │ └── ProductDao.java │ │ │ ├── SpringJDBC.java │ │ │ ├── model │ │ │ └── Product.java │ │ │ └── SpringConfiguration.java │ │ └── resources │ │ └── springXMLConfig.xml ├── nb-configuration.xml └── pom.xml ├── tutorial_hibernate_jpa ├── src │ └── main │ │ ├── resources │ │ ├── schema.sql │ │ └── data.sql │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── jpa │ │ ├── dao │ │ └── ProductDao.java │ │ └── model │ │ └── Product.java └── nb-configuration.xml ├── tutorial_spring_data ├── src │ └── main │ │ ├── resources │ │ └── data │ │ │ ├── schema.sql │ │ │ └── data.sql │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── data │ │ ├── model │ │ └── Product.java │ │ ├── repository │ │ └── ProductRepository.java │ │ └── SpringDataJpa.java └── nb-configuration.xml ├── tutorial_spring_querydsl ├── src │ └── main │ │ ├── resources │ │ └── data │ │ │ ├── schema.sql │ │ │ └── data.sql │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── data │ │ ├── model │ │ └── Product.java │ │ ├── repository │ │ └── ProductRepository.java │ │ └── SpringDataJpa.java └── nb-configuration.xml ├── tutorial_mybatis_spring └── src │ └── main │ └── java │ └── tutor │ └── java │ └── mybatisexample │ ├── service │ ├── CustomerService.java │ └── CustomerServiceImpl.java │ ├── data │ ├── CustomerMapper.java │ └── Customer.java │ └── MyBatisSpringExample.java ├── .gitattributes ├── tutorial_jdbc_template ├── src │ └── main │ │ ├── java │ │ └── carmelo │ │ │ └── spring │ │ │ └── jdbc │ │ │ ├── dao │ │ │ └── ProductDao.java │ │ │ ├── SpringConfiguration.java │ │ │ ├── model │ │ │ └── Product.java │ │ │ └── SpringJDBC.java │ │ └── resources │ │ └── springXMLConfig.xml ├── nb-configuration.xml └── pom.xml ├── tutorial_config_xml ├── src │ └── main │ │ └── java │ │ └── carmelo │ │ └── spring │ │ └── xml │ │ ├── OtherBean.java │ │ ├── ListBean.java │ │ ├── MyBean.java │ │ └── XMLConfig.java ├── nb-configuration.xml └── pom.xml ├── tutorial_AOP_introduccion ├── src │ └── main │ │ └── java │ │ └── tutor │ │ └── programacion │ │ ├── component │ │ └── CrudService.java │ │ ├── aspect │ │ └── LoggingAspect.java │ │ └── springaop │ │ └── TutorialAOP.java └── pom.xml ├── README.md └── .gitignore /tutorial_web_mvc/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/resources/themes/tema-claro.properties: -------------------------------------------------------------------------------- 1 | stylesheet=css/claro.css 2 | name=THEME-CLARO -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/resources/themes/tema-oscuro.properties: -------------------------------------------------------------------------------- 1 | stylesheet=css/oscuro.css 2 | name=THEME-OSCURO -------------------------------------------------------------------------------- /tutorial_webmvc_noxml/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /tutorial_webmvc_anotaciones/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /tutorial_webmvc_controller/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/webapp/css/claro.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: darkslategray; 3 | background-color: whitesmoke; 4 | } -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/webapp/css/oscuro.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: whitesmoke; 3 | background-color: darkgray; 4 | } 5 | -------------------------------------------------------------------------------- /tutorial_properties/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | mensaje: Hello Spring Framework 2 | autor= Tutor de programaci\u00f3n 3 | -------------------------------------------------------------------------------- /tutorial_spring_upload/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE imagen(nombre VARCHAR(100), tipo VARCHAR(10), tamano BIGINT, pixel BLOB(10M)) -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/resources/views.properties: -------------------------------------------------------------------------------- 1 | pdfView.(class)=carmelo.spring.view.PdfView 2 | xlsView.(class)=carmelo.spring.view.XlsView -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | <% response.sendRedirect("product"); %> 4 | 5 | 6 | -------------------------------------------------------------------------------- /tutorial_i18n/src/main/resources/i18n/message_en.properties: -------------------------------------------------------------------------------- 1 | title: Hello I18N with Spring 2 | text: This is a text 3 | saluda: My name is {0} and lastname {1}. -------------------------------------------------------------------------------- /tutorial_spring_upload/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_web_mvc/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_json/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_resources/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/resources/messages_en.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | Email=bla, bla... 4 | NotNull=bla, bla... 5 | 6 | NotBlank=bla, bla... 7 | -------------------------------------------------------------------------------- /tutorial_i18n/src/main/resources/i18n/message_es.properties: -------------------------------------------------------------------------------- 1 | title: Hola I18N con Spring 2 | text: Esto es un texto 3 | saluda: Mi nombre es {0} y mi apellido {1}. -------------------------------------------------------------------------------- /tutorial_webmvc_HandlerMapping/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/src/main/resources/myviews.properties: -------------------------------------------------------------------------------- 1 | home.(class)=org.springframework.web.servlet.view.JstlView 2 | home.url=/WEB-INF/views/home.jsp -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | <% response.sendRedirect("user/form"); %> 4 | 5 | 6 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | interface CustomerService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_i18n/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/resources/messages_en.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | Email=bla, bla... 4 | NotNull=bla, bla... 5 | 6 | NotBlank=bla, bla... 7 | user.name=User Name 8 | -------------------------------------------------------------------------------- /tutorial_beans/src/main/java/carmelo/spring/introduccion/HelloService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | public interface HelloService { 4 | 5 | void saludar(); 6 | } 7 | -------------------------------------------------------------------------------- /tutorial_mvc_custom-validator/tutorial_custom_validator/src/main/webapp/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_introduccion/src/main/java/carmelo/spring/introduccion/HelloService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | public interface HelloService { 4 | 5 | void saludar(); 6 | } 7 | -------------------------------------------------------------------------------- /tutorial_properties/src/main/java/carmelo/spring/introduccion/HelloService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | public interface HelloService { 4 | 5 | void saludar(); 6 | } 7 | -------------------------------------------------------------------------------- /tutorial_springboot-social-facebook/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.social.facebook.appId=120696445248610 2 | spring.social.facebook.appSecret=6c777222f9e3dcb1bff304d04f1a57a9 3 | -------------------------------------------------------------------------------- /tutorial_springboot-social-twitter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.social.twitter.appId=xxxxxxxxxxxxxxxxxxxxxxxxxx 2 | spring.social.twitter.appSecret=xxxxxxxxxxxxxxxxxxxxxxxxxx 3 | 4 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/java/carmelo/spring/model/Tipo.java: -------------------------------------------------------------------------------- 1 | 2 | package carmelo.spring.model; 3 | 4 | public enum Tipo { 5 | Administrador, 6 | Estandar, 7 | Anonimo 8 | } 9 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/service/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | public class CustomerServiceImpl implements CustomerService { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/webapp/WEB-INF/views/userForm.jsp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TutorProgramacion/tutoriales-spring/HEAD/tutorial_webmvc_validacion/src/main/webapp/WEB-INF/views/userForm.jsp -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/webapp/WEB-INF/views/userForm.jsp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TutorProgramacion/tutoriales-spring/HEAD/tutorial_webmvc_thymeleaf_form/src/main/webapp/WEB-INF/views/userForm.jsp -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/resources/messages_es.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | Email=La direcci\u00f3n de correo no es v\u00e1lida 4 | NotNull=No puede ser nulo 5 | 6 | NotBlank=Este campo no puede estar en blanco 7 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/resources/jasperreports/customer_report.jasper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TutorProgramacion/tutoriales-spring/HEAD/tutorial_webmvc_report/src/main/resources/jasperreports/customer_report.jasper -------------------------------------------------------------------------------- /tutorial_webmvc_resources/src/main/webapp/public/images/spring-by-pivotal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TutorProgramacion/tutoriales-spring/HEAD/tutorial_webmvc_resources/src/main/webapp/public/images/spring-by-pivotal.png -------------------------------------------------------------------------------- /tutorial_autowiring/src/main/java/carmelo/spring/autowiring/EmpleadoDao.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.autowiring; 2 | 3 | /** 4 | * 5 | * @author Carmelo Marin Abrego 6 | */ 7 | public interface EmpleadoDao { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_resources/src/main/webapp/public/css/style.css: -------------------------------------------------------------------------------- 1 | .title { 2 | color: darkgreen; 3 | font-family: sans-serif; 4 | display: block; 5 | } 6 | 7 | img { 8 | width: 400px; 9 | height: auto; 10 | } -------------------------------------------------------------------------------- /tutorial_i18n/src/main/java/carmelo/spring/introduccion/service/SaludaService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion.service; 2 | 3 | public interface SaludaService { 4 | 5 | void saluda(String name, String lastname); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /tutorial_autowiring/src/main/java/carmelo/spring/autowiring/EmpleadoService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.autowiring; 2 | 3 | /** 4 | * 5 | * @author Carmelo Marin Abrego 6 | */ 7 | public interface EmpleadoService { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_i18n/src/main/resources/messages_en.properties: -------------------------------------------------------------------------------- 1 | 2 | form.user.nombre=User name 3 | form.user.apellido=Last name 4 | form.user.correo=Email 5 | form.user.edad=User age 6 | form.user.sexo=Gender 7 | form.user.pass=Password 8 | form.user.boton=Send... 9 | -------------------------------------------------------------------------------- /tutorial_jdbc/src/main/java/carmelo/spring/jdbc/dao/ProductDao.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc.dao; 2 | 3 | import carmelo.spring.jdbc.model.Product; 4 | import java.util.List; 5 | 6 | public interface ProductDao { 7 | 8 | List todos(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/resources/messages_es.properties: -------------------------------------------------------------------------------- 1 | mensaje.fecha=La fecha de hoy es: 2 | 3 | Email=La direcci\u00f3n de correo no es v\u00e1lida 4 | NotNull=No puede ser nulo 5 | 6 | NotBlank=Este campo no puede estar en blanco 7 | user.name=Nombre de usuario 8 | -------------------------------------------------------------------------------- /tutorial_webmvc_json/src/main/java/carmelo/spring/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import carmelo.spring.model.Customer; 4 | import java.util.List; 5 | 6 | public interface CustomerService { 7 | 8 | List findAll(); 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/java/carmelo/spring/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import carmelo.spring.model.Customer; 4 | import java.util.List; 5 | 6 | public interface CustomerService { 7 | 8 | List findAll(); 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/java/carmelo/spring/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import carmelo.spring.model.Customer; 4 | import java.util.List; 5 | 6 | public interface CustomerService { 7 | 8 | List findAll(); 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/java/carmelo/spring/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import carmelo.spring.model.Customer; 4 | import java.util.List; 5 | 6 | public interface CustomerService { 7 | 8 | List findAll(); 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/resources/messages_es.properties: -------------------------------------------------------------------------------- 1 | 2 | form.user.nombre=Nombre del usuario 3 | form.user.apellido=Apellido materno y paterno 4 | form.user.correo=Correo electronico 5 | form.user.edad=Edad del usuario 6 | form.user.sexo=Eres hombre 7 | form.user.pass=Tu contrase\u00f1a 8 | -------------------------------------------------------------------------------- /tutorial_autowiring/src/main/java/carmelo/spring/autowiring/EmpleadoDaoImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.autowiring; 2 | 3 | public class EmpleadoDaoImpl implements EmpleadoDao { 4 | 5 | @Override 6 | public String toString() { 7 | return "Logica de acceso a datos..."; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/java/carmelo/spring/report/ReportGenerator.java: -------------------------------------------------------------------------------- 1 | 2 | package carmelo.spring.report; 3 | 4 | import java.util.Map; 5 | import net.sf.jasperreports.engine.JasperReport; 6 | 7 | public interface ReportGenerator { 8 | JasperReport generateReport(Map params); 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/resources/messages_en.properties: -------------------------------------------------------------------------------- 1 | 2 | form.user.nombre=Nombre del usuario 3 | form.user.apellido=Apellido materno y paterno 4 | form.user.correo=Correo electronico 5 | form.user.edad=Edad del usuario 6 | form.user.sexo=Eres hombre o mujer 7 | form.user.pass=Tu contrase\u00f1a 8 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.repository; 2 | 3 | import carmelo.spring.model.Customer; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface CustomerRepository extends CrudRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /tutorial_web_mvc/src/main/webapp/WEB-INF/views/hello.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | Spring Web MVC 6 | 7 | 8 |

${titulo}

9 |

${mensaje}

10 | 11 | 12 | -------------------------------------------------------------------------------- /tutorial_introduccion/src/main/java/carmelo/spring/introduccion/HelloServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | public class HelloServiceImpl implements HelloService { 4 | 5 | @Override 6 | public void saludar() { 7 | System.out.println("\n--- Hello Spring Framework ---\n"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tutorial_webmvc_noxml/src/main/webapp/WEB-INF/views/hello.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | Spring Web MVC 6 | 7 | 8 |

${titulo}

9 |

${mensaje}

10 | 11 | 12 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_i18n/src/main/resources/messages_es.properties: -------------------------------------------------------------------------------- 1 | 2 | form.user.nombre=Nombre del usuario 3 | form.user.apellido=Apellido materno y paterno 4 | form.user.correo=Correo electronico 5 | form.user.edad=Edad del usuario 6 | form.user.sexo=Eres hombre 7 | form.user.pass=Tu contrase\u00f1a 8 | form.user.boton=Enviar... 9 | -------------------------------------------------------------------------------- /tutorial_webmvc_anotaciones/src/main/webapp/WEB-INF/views/hello.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | Spring Web MVC 6 | 7 | 8 |

${titulo}

9 |

${mensaje}

10 | 11 | 12 | -------------------------------------------------------------------------------- /tutorial_webmvc_controller/src/main/webapp/WEB-INF/views/hello.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | Spring Web MVC 6 | 7 | 8 |

${titulo}

9 |

${mensaje}

10 | 11 | 12 | -------------------------------------------------------------------------------- /tutorial_hibernate_jpa/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE Customer( 2 | ID INTEGER PRIMARY KEY, 3 | FirstName VARCHAR(20), 4 | LastName VARCHAR(30), 5 | Street VARCHAR(50), 6 | City VARCHAR(25)); 7 | 8 | CREATE TABLE Product( 9 | ID INTEGER PRIMARY KEY, 10 | Name VARCHAR(30), 11 | Price DECIMAL); -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE Customer( 2 | ID INTEGER PRIMARY KEY, 3 | FirstName VARCHAR(20), 4 | LastName VARCHAR(30), 5 | Street VARCHAR(50), 6 | City VARCHAR(25)); 7 | 8 | CREATE TABLE Product( 9 | ID INTEGER PRIMARY KEY, 10 | Name VARCHAR(30), 11 | Price DOUBLE); -------------------------------------------------------------------------------- /tutorial_spring_data/src/main/resources/data/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE Customer( 2 | ID INTEGER PRIMARY KEY, 3 | FirstName VARCHAR(20), 4 | LastName VARCHAR(30), 5 | Street VARCHAR(50), 6 | City VARCHAR(25)); 7 | 8 | CREATE TABLE Product( 9 | ID INTEGER PRIMARY KEY, 10 | Name VARCHAR(30), 11 | Price DECIMAL); -------------------------------------------------------------------------------- /tutorial_spring_querydsl/src/main/resources/data/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE Customer( 2 | ID INTEGER PRIMARY KEY, 3 | FirstName VARCHAR(20), 4 | LastName VARCHAR(30), 5 | Street VARCHAR(50), 6 | City VARCHAR(25)); 7 | 8 | CREATE TABLE Product( 9 | ID INTEGER PRIMARY KEY, 10 | Name VARCHAR(30), 11 | Price DECIMAL); -------------------------------------------------------------------------------- /tutorial_mybatis_spring/src/main/java/tutor/java/mybatisexample/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package tutor.java.mybatisexample.service; 2 | 3 | import java.util.List; 4 | import tutor.java.mybatisexample.data.Customer; 5 | 6 | public interface CustomerService { 7 | 8 | List findAll(); 9 | 10 | Customer findOne(Long id); 11 | } 12 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | Spring MVC ViewResolver 6 | 7 | 8 |

Home.jsp :: ViewResolver

9 |

${msg}

10 | 11 | 12 | -------------------------------------------------------------------------------- /tutorial_webmvc_json/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n 6 | 7 | log4j.category.org.springframework.beans.factory=ERROR -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n 6 | 7 | log4j.category.org.springframework.beans.factory=ERROR -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n 6 | 7 | log4j.category.org.springframework.beans.factory=ERROR -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n 6 | 7 | log4j.category.org.springframework.beans.factory=ERROR -------------------------------------------------------------------------------- /tutorial_properties/src/main/resources/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TODO supply a title 5 | 6 | 7 | 8 | 9 |
TODO write content
10 | 11 | 12 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n 6 | 7 | log4j.category.org.springframework.beans.factory=ERROR -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/model/Product.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.model; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | @Entity 10 | public class Product { 11 | 12 | @Id private Long id; 13 | private String name; 14 | private Double price; 15 | } 16 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import carmelo.spring.model.Product; 4 | 5 | public interface ProductService { 6 | 7 | Iterable productList(); 8 | 9 | void productDelete(Long id); 10 | 11 | void productAdd(Product product); 12 | 13 | Long productCount(); 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_beans/src/main/java/carmelo/spring/introduccion/ClientService.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | public class ClientService { 4 | 5 | private static ClientService clientService = new ClientService(); 6 | 7 | private ClientService() { 8 | } 9 | 10 | public static ClientService createInstance() { 11 | return clientService; 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tutorial_spring_data/src/main/java/carmelo/spring/data/model/Product.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.data.model; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | @Entity 10 | public class Product { 11 | 12 | @Id 13 | private Long id; 14 | 15 | private String name; 16 | 17 | private Double price; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/java/carmelo/spring/model/Customer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class Customer { 9 | private Long id; 10 | private String firstName; 11 | private String lastName; 12 | private String street; 13 | private String city; 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_spring_querydsl/src/main/java/carmelo/spring/data/model/Product.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.data.model; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | @Entity 10 | public class Product { 11 | 12 | @Id 13 | private Long id; 14 | 15 | private String name; 16 | 17 | private Double price; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/java/carmelo/spring/model/Customer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class Customer { 9 | private Integer ID; 10 | private String FIRSTNAME; 11 | private String LASTNAME; 12 | private String STREET; 13 | private String CITY; 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/java/carmelo/spring/model/Customer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class Customer { 9 | private Integer ID; 10 | private String FIRSTNAME; 11 | private String LASTNAME; 12 | private String STREET; 13 | private String CITY; 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_springboot-social-facebook/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /tutorial_springboot-social-twitter/src/main/java/hello/Application.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tutorial_springboot-social-twitter/src/main/resources/templates/connect/twitterConnected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello Twitter 4 | 5 | 6 |

Connected to Twitter

7 | 8 |

9 | App conectada a tu cuenta de Twitter.
10 | Ir al App y ver mis tweets. 11 |

12 | 13 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.repository; 2 | 3 | import java.util.List; 4 | import carmelo.spring.model.Product; 5 | import org.springframework.data.repository.CrudRepository; 6 | 7 | public interface ProductRepository extends CrudRepository { 8 | 9 | List findByPriceGreaterThan(Double price); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/src/main/webapp/WEB-INF/views/index.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | Spring MVC ViewResolver 7 | 8 | 9 |

Index.jsp :: ViewResolver

10 |

${msg}

11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/model/Customer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.model; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import lombok.Data; 6 | 7 | @Data 8 | @Entity 9 | public class Customer { 10 | 11 | @Id private Long id; 12 | 13 | private String firstName; 14 | private String lastName; 15 | private String street; 16 | private String city; 17 | } 18 | -------------------------------------------------------------------------------- /tutorial_properties/src/main/java/carmelo/spring/introduccion/HelloServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | public class HelloServiceImpl implements HelloService { 4 | 5 | private String msg; 6 | 7 | public HelloServiceImpl(String msg) { 8 | this.msg = msg; 9 | } 10 | 11 | @Override 12 | public void saludar() { 13 | System.out.println("\n--- " + msg + " ---\n"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tutorial_springboot-social-facebook/src/main/resources/templates/connect/facebookConnected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Spring Facebook 4 | 5 | 6 |

Conectado a Facebook

7 | 8 |

9 | Tu cuenta de Facebook está conectada a la App. 10 | Click aquí para ver tus publicaciones y perfil. 11 |

12 | 13 | -------------------------------------------------------------------------------- /tutorial_webmvc_controller/src/main/webapp/WEB-INF/views/ventas.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | Tutoriales Spring MVC 7 | 8 | 9 |

Estas son la ventas de: ${vendedor}

10 |

${ventas}

11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_introduccion/src/main/java/carmelo/spring/introduccion/SpringConfiguration.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class SpringConfiguration { 8 | 9 | @Bean 10 | public HelloService saludaService(){ 11 | return new HelloServiceImpl(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /tutorial_mvc_custom-validator/tutorial_custom_validator/src/main/webapp/WEB-INF/views/valid.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | Person Valid 7 | 8 | 9 |

La persona ha sido registrada correctamente

10 |

${person}

11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_mybatis_spring/src/main/java/tutor/java/mybatisexample/data/CustomerMapper.java: -------------------------------------------------------------------------------- 1 | package tutor.java.mybatisexample.data; 2 | 3 | import java.util.List; 4 | import org.apache.ibatis.annotations.Select; 5 | 6 | public interface CustomerMapper { 7 | 8 | @Select("SELECT * FROM Customer WHERE id = #{id}") 9 | Customer selectCustomerById(long id); 10 | 11 | @Select("SELECT * FROM Customer") 12 | List selectAllCustomer(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_spring_querydsl/src/main/java/carmelo/spring/data/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.data.repository; 2 | 3 | import carmelo.spring.data.model.Product; 4 | import org.springframework.data.querydsl.QueryDslPredicateExecutor; 5 | import org.springframework.data.repository.CrudRepository; 6 | 7 | public interface ProductRepository extends 8 | CrudRepository, 9 | QueryDslPredicateExecutor { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /tutorial_hibernate_jpa/src/main/java/carmelo/spring/jpa/dao/ProductDao.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jpa.dao; 2 | 3 | import carmelo.spring.jpa.model.Product; 4 | import java.util.List; 5 | 6 | public interface ProductDao { 7 | 8 | List todos(); 9 | 10 | Integer cantidad(); 11 | 12 | Product buscar(Integer id); 13 | 14 | void insertar(Product product); 15 | 16 | void actualizar(Product product); 17 | 18 | void eliminar(Integer id); 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/webapp/WEB-INF/views/userReady.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html; charset=ISO-8859-1" %> 2 | 3 | 4 | 5 | Spring MVC Form Validation 6 | 7 | 8 |

Usuario creado correctamente:

9 |

${usuario.nombre}, ${usuario.apellido}

10 | Crear usuario 11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/webapp/WEB-INF/views/userReady.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html; charset=ISO-8859-1" %> 2 | 3 | 4 | 5 | Spring MVC Form Validation 6 | 7 | 8 |

Usuario creado correctamente:

9 |

${usuario.nombre}, ${usuario.apellido}

10 | Crear usuario 11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_jdbc_template/src/main/java/carmelo/spring/jdbc/dao/ProductDao.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc.dao; 2 | 3 | import carmelo.spring.jdbc.model.Product; 4 | import java.util.List; 5 | 6 | public interface ProductDao { 7 | 8 | List todos(); 9 | 10 | Integer cantidad(); 11 | 12 | Product buscar(Integer id); 13 | 14 | void insertar(Product product); 15 | 16 | void actualizar(Product product); 17 | 18 | void eliminar(Integer id); 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_resources/src/main/java/carmelo/spring/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class HomeController { 9 | 10 | @RequestMapping("/") 11 | public ModelAndView homePage() { 12 | return new ModelAndView("home"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_config_xml/src/main/java/carmelo/spring/xml/OtherBean.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.xml; 2 | 3 | public class OtherBean { 4 | 5 | private MyBean myBean; 6 | 7 | public OtherBean() { 8 | } 9 | 10 | public OtherBean(MyBean myBean) { 11 | this.myBean = myBean; 12 | } 13 | 14 | public MyBean getMyBean() { 15 | return myBean; 16 | } 17 | 18 | public void setMyBean(MyBean myBean) { 19 | this.myBean = myBean; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/java/carmelo/spring/controller/ThemeController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class ThemeController { 9 | 10 | @RequestMapping("/") 11 | public ModelAndView homePage() { 12 | return new ModelAndView("home"); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/webapp/WEB-INF/templates/userReady.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TODO supply a title 5 | 6 | 7 | 8 | 9 |

Nuevo usuario registrado

10 |

11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_i18n/src/main/webapp/WEB-INF/templates/userReady.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TODO supply a title 5 | 6 | 7 | 8 | 9 |

Nuevo usuario registrado

10 |

11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/src/main/java/carmelo/spring/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class HomeController { 9 | 10 | @RequestMapping("/") 11 | public ModelAndView homePage() { 12 | return new ModelAndView("home", "msg", "Usando la interface ViewResolver."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_webmvc_HandlerMapping/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | HandlerMapping 6 | 7 | 8 | 9 |

Spring MVC :: HandlerMapping

10 |

Tutoriales Spring MVC by Tutor de Programacion.

11 |

Estudiando el componente HandlerMapping.

12 | 13 | 14 | -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 2 | 3 | 4 | 5 | 6 | Spring MVC ThemeResolver 7 | 8 | 9 | 10 |

Spring MVC ThemeResolver

11 |

Tema actual:

12 | aplicar tema: claro | oscuro 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/src/main/webapp/WEB-INF/views.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_beans/src/main/java/carmelo/spring/introduccion/SpringConfiguration.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.Scope; 7 | 8 | @Configuration 9 | //@ComponentScan 10 | public class SpringConfiguration { 11 | 12 | @Bean("saludaService") 13 | // @Scope("prototype") 14 | public HelloService getSaludaService(){ 15 | return new HelloServiceImpl(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tutorial_spring_data/src/main/java/carmelo/spring/data/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.data.repository; 2 | 3 | import java.util.List; 4 | import carmelo.spring.data.model.Product; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.CrudRepository; 7 | import org.springframework.data.repository.query.Param; 8 | 9 | public interface ProductRepository extends CrudRepository { 10 | 11 | @Query("select p from Product p where p.price > :precio") 12 | List findByPriceGreaterThan(@Param("precio") Double price); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tutorial_spring_upload/src/main/webapp/WEB-INF/views/image.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Document : image.jsp 3 | Created on : 07/19/2017, 11:02:20 AM 4 | Author : Tutor de programación 5 | --%> 6 | 7 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 8 | 9 | 10 | 11 | 12 | Image View 13 | 14 | 15 |

Visor de Imagen

16 |

Mostrando la imagen: ${nombre}

17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tutorial_autowiring/src/main/java/carmelo/spring/autowiring/SpringJavaConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.autowiring; 2 | 3 | import org.springframework.beans.factory.annotation.Autowire; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | //@Configuration 8 | public class SpringJavaConfig { 9 | 10 | @Bean 11 | public EmpleadoDao empleadoDao() { 12 | return new EmpleadoDaoImpl(); 13 | } 14 | 15 | @Bean(autowire = Autowire.BY_TYPE) 16 | public EmpleadoService empleadoService() { 17 | return new EmpleadoServiceImpl(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_springboot-social-facebook/src/main/resources/templates/connect/facebookConnect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Connect Facebook 4 | 5 | 6 |

Connectar a Facebook

7 | 8 |
9 | 10 |
11 |

Aun no estás conectado a Facebook, presiona el botón para conectar con tu cuenta.

12 |
13 |

14 |
15 | 16 | -------------------------------------------------------------------------------- /tutorial_autowiring/src/main/java/carmelo/spring/autowiring/EmpleadoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.autowiring; 2 | 3 | public class EmpleadoServiceImpl implements EmpleadoService { 4 | 5 | private EmpleadoDao empleadoDao; 6 | 7 | public EmpleadoServiceImpl() { 8 | 9 | } 10 | 11 | public EmpleadoServiceImpl(EmpleadoDao empleadoDao) { 12 | this.empleadoDao = empleadoDao; 13 | } 14 | 15 | public void setEmpleadoDao(EmpleadoDao empleadoDao) { 16 | this.empleadoDao = empleadoDao; 17 | } 18 | 19 | public EmpleadoDao getEmpleadoDao() { 20 | return empleadoDao; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tutorial_config_xml/src/main/java/carmelo/spring/xml/ListBean.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.xml; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | public class ListBean { 7 | 8 | private List items; 9 | 10 | public List getItems() { 11 | return items; 12 | } 13 | 14 | public void setItems(List items) { 15 | this.items = items; 16 | } 17 | 18 | private Set beanItems; 19 | 20 | public void setBeanItems(Set beanItems) { 21 | this.beanItems = beanItems; 22 | } 23 | 24 | public Set getBeanItems() { 25 | return beanItems; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tutorial_webmvc_json/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_resources/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_HandlerMapping/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_springboot-social-twitter/src/main/resources/templates/connect/twitterConnect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello Twitter 4 | 5 | 6 |

Connect to Twitter

7 | Provider error (asegurate con configurar el appId y consumerKey) 8 |
9 |
10 |

Aun no estas conectado a Twitter, presiona el boton para conectar el App con tu cuenta.

11 |
12 |

13 |
14 | 15 | -------------------------------------------------------------------------------- /tutorial_web_mvc/src/main/java/carmelo/spring/webmvc/HelloController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.webmvc; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class HelloController { 9 | 10 | @RequestMapping(value = "/hello") 11 | public ModelAndView saluda() { 12 | ModelAndView mv = new ModelAndView(); 13 | mv.addObject("titulo", "Tutoriales Spring MVC"); 14 | mv.addObject("mensaje", "Mi Primera Aplicacion Web Spring MVC"); 15 | mv.setViewName("hello"); 16 | 17 | return mv; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_theme/src/main/java/carmelo/spring/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/src/main/java/carmelo/spring/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_noxml/src/main/java/carmelo/spring/webmvc/HelloController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.webmvc; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class HelloController { 9 | 10 | @RequestMapping(value = "/hello") 11 | public ModelAndView saluda() { 12 | ModelAndView mv = new ModelAndView(); 13 | mv.addObject("titulo", "Tutoriales Spring MVC"); 14 | mv.addObject("mensaje", "Mi Primera Aplicacion Web Spring MVC"); 15 | mv.setViewName("hello"); 16 | 17 | return mv; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/java/carmelo/spring/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/java/carmelo/spring/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_anotaciones/src/main/java/carmelo/spring/webmvc/HelloController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.webmvc; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | @Controller 8 | public class HelloController { 9 | 10 | @RequestMapping(value = "/hello") 11 | public ModelAndView saluda() { 12 | ModelAndView mv = new ModelAndView(); 13 | mv.addObject("titulo", "Tutoriales Spring MVC"); 14 | mv.addObject("mensaje", "Mi Primera Aplicacion Web Spring MVC"); 15 | mv.setViewName("hello"); 16 | 17 | return mv; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/java/carmelo/spring/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_i18n/src/main/java/carmelo/spring/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_noxml/src/main/java/carmelo/spring/config/MyWebApplicationInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class MyWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{AppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return new Class[]{RootAppConfig.class}; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_mvc_custom-validator/tutorial_custom_validator/src/main/java/carmelo/spring/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{WebAppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_webmvc_controller/src/main/java/carmelo/spring/config/MyWebApplicationInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class MyWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return null; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{AppConfig.class}; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_spring_upload/src/main/java/carmelo/spring/config/WebAppInitializer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getRootConfigClasses() { 9 | return new Class[]{ WebAppData.class }; 10 | } 11 | 12 | @Override 13 | protected Class[] getServletConfigClasses() { 14 | return new Class[]{ WebAppConfig.class }; 15 | } 16 | 17 | @Override 18 | protected String[] getServletMappings() { 19 | return new String[]{"/"}; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tutorial_jdbc/src/main/java/carmelo/spring/jdbc/SpringJDBC.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc; 2 | 3 | import java.sql.SQLException; 4 | import carmelo.spring.jdbc.dao.ProductDao; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.support.AbstractApplicationContext; 7 | 8 | public class SpringJDBC { 9 | 10 | public static void main(String[] args) throws SQLException { 11 | 12 | AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfiguration.class); 13 | 14 | ProductDao product = ctx.getBean(ProductDao.class); 15 | product.todos().forEach(System.out::println); 16 | 17 | ctx.close(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_AOP_introduccion/src/main/java/tutor/programacion/component/CrudService.java: -------------------------------------------------------------------------------- 1 | package tutor.programacion.component; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class CrudService { 7 | 8 | public void create() { 9 | System.out.println("crear dato..."); 10 | } 11 | 12 | public void read() { 13 | System.out.println("leer dato..."); 14 | } 15 | 16 | public void update() { 17 | try { 18 | Thread.sleep(377); 19 | System.out.println("actualizar dato..."); 20 | } catch (InterruptedException ex) { 21 | 22 | } 23 | } 24 | 25 | public void delete() { 26 | System.out.println("eliminar dato..."); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tutorial_i18n/src/main/java/carmelo/spring/introduccion/service/SaludaServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion.service; 2 | 3 | import java.util.Locale; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.MessageSource; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class SaludaServiceImpl implements SaludaService { 10 | 11 | @Autowired 12 | private MessageSource ms; 13 | 14 | @Override 15 | public void saluda(String name, String lastname) { 16 | System.out.println( 17 | ms.getMessage("saluda", 18 | new Object[]{name, lastname}, 19 | Locale.ENGLISH)); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /tutorial_config_xml/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/beans.xml 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tutorial_web_mvc/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | springmvc 7 | 8 | org.springframework.web.servlet.DispatcherServlet 9 | 10 | 1 11 | 12 | 13 | 14 | springmvc 15 | / 16 | 17 | 18 | -------------------------------------------------------------------------------- /tutorial_i18n/src/main/java/carmelo/spring/introduccion/SpringConfiguration.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.support.ResourceBundleMessageSource; 7 | 8 | @Configuration 9 | @ComponentScan(basePackages = "carmelo.spring.introduccion") 10 | public class SpringConfiguration { 11 | 12 | @Bean 13 | public ResourceBundleMessageSource messageSource() { 14 | ResourceBundleMessageSource rbms = new ResourceBundleMessageSource(); 15 | rbms.setBasename("i18n/message"); 16 | return rbms; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_introduccion/src/main/resources/springXMLConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_i18n/src/main/resources/springXMLConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tutorial_webmvc_noxml/src/main/java/carmelo/spring/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 7 | 8 | @Configuration 9 | @ComponentScan(basePackages = {"carmelo.spring.webmvc"}) 10 | public class AppConfig { 11 | 12 | @Bean 13 | public InternalResourceViewResolver getInternalResourceViewResolver() { 14 | InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 15 | resolver.setPrefix("/WEB-INF/views/"); 16 | resolver.setSuffix(".jsp"); 17 | return resolver; 18 | } 19 | } -------------------------------------------------------------------------------- /tutorial_mybatis_spring/src/main/java/tutor/java/mybatisexample/service/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package tutor.java.mybatisexample.service; 2 | 3 | import java.util.List; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | import tutor.java.mybatisexample.data.Customer; 7 | import tutor.java.mybatisexample.data.CustomerMapper; 8 | 9 | @Service 10 | public class CustomerServiceImpl implements CustomerService { 11 | 12 | @Autowired 13 | private CustomerMapper mapper; 14 | 15 | @Override 16 | public List findAll() { 17 | return mapper.selectAllCustomer(); 18 | } 19 | 20 | @Override 21 | public Customer findOne(Long id) { 22 | return mapper.selectCustomerById(id); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_controller/src/main/java/carmelo/spring/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 7 | 8 | @Configuration 9 | @ComponentScan(basePackages = {"carmelo.spring.controller"}) 10 | public class AppConfig { 11 | 12 | @Bean 13 | public InternalResourceViewResolver getInternalResourceViewResolver() { 14 | InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 15 | resolver.setPrefix("/WEB-INF/views/"); 16 | resolver.setSuffix(".jsp"); 17 | return resolver; 18 | } 19 | } -------------------------------------------------------------------------------- /tutorial_webmvc_anotaciones/src/main/java/carmelo/spring/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 7 | 8 | @Configuration 9 | @ComponentScan(basePackages = {"carmelo.spring.webmvc"}) 10 | public class AppConfig { 11 | 12 | @Bean 13 | public InternalResourceViewResolver getInternalResourceViewResolver() { 14 | InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 15 | resolver.setPrefix("/WEB-INF/views/"); 16 | resolver.setSuffix(".jsp"); 17 | return resolver; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tutorial_webmvc_HandlerMapping/src/main/java/carmelo/spring/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.servlet.ModelAndView; 9 | import org.springframework.web.servlet.mvc.AbstractController; 10 | 11 | public class HomeController extends AbstractController { 12 | 13 | @Override 14 | protected ModelAndView handleRequestInternal( 15 | HttpServletRequest request, 16 | HttpServletResponse response) throws Exception { 17 | 18 | return new ModelAndView("home"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tutorial_beans/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/beans.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_jdbc/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/beans.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_autowiring/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/beans.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_spring_data/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/beans.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/webapp/WEB-INF/views/customer.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 2 | 3 | 4 | 5 | 6 | 7 | Customer Report 8 | 9 | 10 |

Customer JasperReport Application

11 |

Esta aplicacion muestra como generar reportes con JasperReport en una aplicacion web Spring MVC.

12 | 13 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tutorial_hibernate_jpa/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/beans.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_jdbc_template/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/beans.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_spring_querydsl/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/beans.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/webapp/WEB-INF/views/customer.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 2 | 3 | 4 | 5 | 6 | 7 | Customer Report 8 | 9 | 10 |

Customer JasperReport Application

11 |

Esta aplicacion muestra como generar reportes con JasperReport en una aplicacion web Spring MVC.

12 | 13 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tutorial_i18n/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/newSpringXMLConfig.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_introduccion/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/newSpringXMLConfig.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_properties/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/resources/springXMLConfig.xml 12 | src/main/resources/newSpringXMLConfig.xml 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tutorial_config_xml/src/main/java/carmelo/spring/xml/MyBean.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.xml; 2 | 3 | public class MyBean { 4 | 5 | public MyBean() { 6 | } 7 | 8 | public MyBean(Integer valor, String mensaje) { 9 | this.valor = valor; 10 | this.mensaje = mensaje; 11 | } 12 | 13 | private Integer valor; 14 | private String mensaje; 15 | 16 | public Integer getValor() { 17 | return valor; 18 | } 19 | 20 | public void setValor(Integer valor) { 21 | this.valor = valor; 22 | } 23 | 24 | public String getMensaje() { 25 | return mensaje; 26 | } 27 | 28 | public void setMensaje(String mensaje) { 29 | this.mensaje = mensaje; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "MyBean{" + "valor=" + valor + ", mensaje=" + mensaje + '}'; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /tutorial_jdbc/src/main/java/carmelo/spring/jdbc/model/Product.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc.model; 2 | 3 | public class Product { 4 | 5 | private Integer id; 6 | private String name; 7 | private Double price; 8 | 9 | public Integer getId() { 10 | return id; 11 | } 12 | 13 | public void setId(Integer id) { 14 | this.id = id; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public Double getPrice() { 26 | return price; 27 | } 28 | 29 | public void setPrice(Double price) { 30 | this.price = price; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "Product{" + "id=" + id + ", name=" + name + ", price=" + price + '}'; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /tutorial_webmvc_json/src/main/java/carmelo/spring/model/Customer.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonView; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | public class Customer { 11 | 12 | public interface TestView {}; 13 | public interface FullNameView { }; 14 | public interface FullNameAndDirectionView extends FullNameView { }; 15 | 16 | private Long id; 17 | 18 | @JsonView(value = {FullNameView.class, TestView.class}) 19 | private String firstName; 20 | 21 | @JsonView(FullNameView.class) 22 | private String lastName; 23 | 24 | @JsonView(FullNameAndDirectionView.class) 25 | private String street; 26 | 27 | @JsonView(TestView.class) 28 | private String city; 29 | } 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tutoriales Spring Framework (español) 2 | 3 | Serie de tutoriales Java en los que aprenderemos a utilizar uno de los framework más populares del momento, hablamos de **Spring**, en esta serie de cursos veremos cada uno de los módulos que lo componen o como utilizarlos en nuestros proyectos de software, cada uno de los tutoriales contará con su respectivo código de ejemplo. 4 | 5 | Algunas de los temas que trataremos son: 6 | 7 | * Configuración del contenedor spring con XML, Anotaciones y Código Java. 8 | * Acceso a datos mediante JDBC API. 9 | * Integración con el ORM Hibernate JPA. 10 | * Acceso a datos con SpringData. 11 | * Creación de aplicaciones web con Spring MVC. 12 | * Desarrollo de aplicaciones con Spring Boot 13 | * Cualquier otra cosa que se me ocurra en el camino. 14 | 15 | Puedes seguir el avance de los tutoriales en: [Programación Spring Framework](http://acodigo.blogspot.com/p/spring.html) 16 | -------------------------------------------------------------------------------- /tutorial_jdbc/src/main/java/carmelo/spring/jdbc/SpringConfiguration.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc; 2 | 3 | import javax.sql.DataSource; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 8 | 9 | @Configuration 10 | @ComponentScan(basePackages = "carmelo.spring.jdbc.dao") 11 | public class SpringConfiguration { 12 | 13 | @Bean 14 | public DataSource dataSource() { 15 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 16 | dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); 17 | dataSource.setUrl("jdbc:hsqldb:hsql://localhost/"); 18 | dataSource.setUsername("SA"); 19 | dataSource.setPassword(""); 20 | return dataSource; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tutorial_autowiring/src/main/resources/springXMLConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 12 | 13 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tutorial_mybatis_spring/src/main/java/tutor/java/mybatisexample/MyBatisSpringExample.java: -------------------------------------------------------------------------------- 1 | package tutor.java.mybatisexample; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | 5 | import tutor.java.mybatisexample.data.CustomerMapper; 6 | import tutor.java.mybatisexample.service.CustomerService; 7 | 8 | public class MyBatisSpringExample { 9 | 10 | public static void main(String[] args) { 11 | 12 | AnnotationConfigApplicationContext ctx 13 | = new AnnotationConfigApplicationContext(AppConfig.class); 14 | 15 | // CustomerMapper cm = ctx.getBean(CustomerMapper.class); 16 | // cm.selectAllCustomer().forEach(System.out::println); 17 | 18 | ctx.scan("tutor.java.mybatisexample.service"); 19 | 20 | CustomerService cs = ctx.getBean(CustomerService.class); 21 | cs.findAll().forEach(System.out::println); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tutorial_jdbc_template/src/main/java/carmelo/spring/jdbc/SpringConfiguration.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc; 2 | 3 | import javax.sql.DataSource; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 8 | 9 | @Configuration 10 | @ComponentScan(basePackages = "carmelo.spring.jdbc.dao") 11 | public class SpringConfiguration { 12 | 13 | @Bean 14 | public DataSource dataSource() { 15 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 16 | dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); 17 | dataSource.setUrl("jdbc:hsqldb:hsql://localhost/"); 18 | dataSource.setUsername("SA"); 19 | dataSource.setPassword(""); 20 | return dataSource; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.ViewResolver; 7 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 8 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 9 | 10 | @Configuration 11 | @EnableWebMvc 12 | @ComponentScan(basePackages = {"carmelo.spring.controller"}) 13 | public class WebAppConfig { 14 | 15 | @Bean 16 | public ViewResolver getInternalResourceViewResolver() { 17 | InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 18 | resolver.setPrefix("/WEB-INF/views/"); 19 | resolver.setSuffix(".jsp"); 20 | return resolver; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tutorial_spring_upload/src/main/java/carmelo/spring/config/WebAppData.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import javax.sql.DataSource; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.jdbc.core.JdbcTemplate; 7 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; 8 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; 9 | 10 | @Configuration 11 | public class WebAppData { 12 | 13 | @Bean 14 | public DataSource dataSource() { 15 | return new EmbeddedDatabaseBuilder() 16 | .setType(EmbeddedDatabaseType.HSQL) 17 | .addScript("classpath:schema.sql") 18 | .build(); 19 | } 20 | 21 | @Bean 22 | public JdbcTemplate jdbcTemplate(DataSource dataSource) { 23 | return new JdbcTemplate(dataSource); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tutorial_config_xml/src/main/java/carmelo/spring/xml/XMLConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.xml; 2 | 3 | import org.springframework.context.support.AbstractApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | public class XMLConfig { 7 | 8 | public static void main(String[] args) { 9 | try(AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml")){ 10 | 11 | //MyBean bean = ctx.getBean("mybean", MyBean.class); 12 | 13 | OtherBean other = ctx.getBean("otherbean", OtherBean.class); 14 | MyBean bean = other.getMyBean(); 15 | 16 | System.out.println("--> " + bean.getValor() + " - " + bean.getMensaje() + " <--"); 17 | 18 | ListBean list = ctx.getBean("listbean", ListBean.class); 19 | list.getBeanItems().forEach(System.out::println); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tutorial_properties/src/main/java/carmelo/spring/introduccion/Introduccion.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.support.AbstractApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | public class Introduccion { 8 | 9 | public static void main(String[] args) { 10 | 11 | // configuracion con archivo XML 12 | //AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("springXMLConfig.xml"); 13 | 14 | // configuracion con codigo java 15 | AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfiguration.class); 16 | 17 | HelloService saluda = ctx.getBean("saludaService", HelloService.class); 18 | saluda.saludar(); 19 | 20 | ctx.close(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tutorial_introduccion/src/main/java/carmelo/spring/introduccion/Introduccion.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.support.AbstractApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | public class Introduccion { 8 | 9 | public static void main(String[] args) { 10 | 11 | // configuracion con archivo XML 12 | //AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("springXMLConfig.xml"); 13 | 14 | // configuracion con codigo java 15 | AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfiguration.class); 16 | 17 | HelloService saluda = ctx.getBean("saludaService", HelloService.class); 18 | saluda.saludar(); 19 | 20 | ctx.close(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/java/carmelo/spring/service/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import carmelo.spring.model.Product; 4 | import carmelo.spring.repository.ProductRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class ProductServiceImpl implements ProductService { 10 | 11 | @Autowired 12 | private ProductRepository product; 13 | 14 | @Override 15 | public Iterable productList() { 16 | return product.findAll(); 17 | } 18 | 19 | @Override 20 | public void productDelete(Long id) { 21 | this.product.delete(id); 22 | } 23 | 24 | @Override 25 | public void productAdd(Product product) { 26 | this.product.save(product); 27 | } 28 | 29 | @Override 30 | public Long productCount() { 31 | return this.product.count(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tutorial_webmvc_json/src/main/java/carmelo/spring/service/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import carmelo.spring.model.Customer; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class CustomerServiceImpl implements CustomerService { 10 | 11 | @Override 12 | public List findAll() { 13 | 14 | Customer customer1 = new Customer(1L, "Juan", "Uno", "Calle 274", "Veraguas"); 15 | Customer customer2 = new Customer(2L, "Pedro", "Dos", "Calle 004", "Chiriqui"); 16 | Customer customer3 = new Customer(3L, "Miguel", "Tres", "Calle 174", "Darien"); 17 | Customer customer4 = new Customer(4L, "Daniel", "Cuatro", "Calle 284", "Colon"); 18 | Customer customer5 = new Customer(5L, "Ramiro", "Cinco", "Calle 277", "Panama"); 19 | 20 | return Arrays.asList(customer1, customer2, customer3, customer4, customer5); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/java/carmelo/spring/service/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.service; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import carmelo.spring.model.Customer; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class CustomerServiceImpl implements CustomerService { 10 | 11 | @Override 12 | public List findAll() { 13 | 14 | Customer customer1 = new Customer(1L, "Juan", "Uno", "Calle 274", "Veraguas"); 15 | Customer customer2 = new Customer(2L, "Pedro", "Dos", "Calle 004", "Chiriqui"); 16 | Customer customer3 = new Customer(3L, "Miguel", "Tres", "Calle 174", "Darien"); 17 | Customer customer4 = new Customer(4L, "Daniel", "Cuatro", "Calle 284", "Colon"); 18 | Customer customer5 = new Customer(5L, "Ramiro", "Cinco", "Calle 277", "Panama"); 19 | 20 | return Arrays.asList(customer1, customer2, customer3, customer4, customer5); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /tutorial_web_mvc/src/main/webapp/WEB-INF/springmvc-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /tutorial_beans/src/main/resources/springXMLConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tutorial_i18n/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_i18n 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 1.8 21 | 22 | 23 | -------------------------------------------------------------------------------- /tutorial_jdbc/src/main/resources/springXMLConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tutorial_introduccion/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_introduccion 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 1.8 21 | 22 | 23 | -------------------------------------------------------------------------------- /tutorial_springboot-social-facebook/src/main/resources/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spring Social Facebook 5 | 16 | 17 | 18 | 19 |

Hola, usuario !

20 | 21 |

Estas son tus publicaciones:

22 | 23 |
24 | autor publicó: 25 |

mensaje

26 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /tutorial_autowiring/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_autowiring 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 1.8 21 | 22 | 23 | -------------------------------------------------------------------------------- /tutorial_beans/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_configuracion 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 1.8 21 | 22 | 23 | -------------------------------------------------------------------------------- /tutorial_jdbc_template/src/main/resources/springXMLConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tutorial_properties/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_properties 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 1.8 21 | 22 | 23 | -------------------------------------------------------------------------------- /tutorial_AOP_introduccion/src/main/java/tutor/programacion/aspect/LoggingAspect.java: -------------------------------------------------------------------------------- 1 | package tutor.programacion.aspect; 2 | 3 | import java.time.LocalDateTime; 4 | import org.aspectj.lang.JoinPoint; 5 | import org.aspectj.lang.annotation.After; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.aspectj.lang.annotation.Before; 8 | import org.aspectj.lang.annotation.Pointcut; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Aspect 12 | @Component 13 | public class LoggingAspect { 14 | 15 | @Pointcut("execution(* tutor.programacion.component.*.*(..))") 16 | public void serviceMethod() { } 17 | 18 | @Before("serviceMethod()") 19 | public void beforeLoginAdvice(JoinPoint jp) { 20 | System.out.println("\n" + jp.toLongString()); 21 | System.out.println("iniciado " + LocalDateTime.now()); 22 | } 23 | 24 | @After("serviceMethod()") 25 | public void afterLoginAdvice() { 26 | System.out.println("finalizado " + LocalDateTime.now()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /tutorial_config_xml/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring.xml 5 | tutorial_config_xml 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | 17 | 18 | UTF-8 19 | 1.8 20 | 1.8 21 | 22 | 23 | -------------------------------------------------------------------------------- /tutorial_webmvc_resources/src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | Contenido estatico 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 |

Tutoriales Spring Framework

21 | Spring Image 22 |
23 | Font Awesome Icon 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_anotaciones/src/main/webapp/WEB-INF/springmvc-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tutorial_AOP_introduccion/src/main/java/tutor/programacion/springaop/TutorialAOP.java: -------------------------------------------------------------------------------- 1 | 2 | package tutor.programacion.springaop; 3 | 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 9 | import tutor.programacion.component.CrudService; 10 | 11 | @Configuration 12 | @ComponentScan({"tutor.programacion.aspect", "tutor.programacion.component"}) 13 | @EnableAspectJAutoProxy 14 | public class TutorialAOP { 15 | 16 | public static void main(String[] args) { 17 | ApplicationContext ctx = new AnnotationConfigApplicationContext(TutorialAOP.class); 18 | 19 | CrudService ps = ctx.getBean(CrudService.class); 20 | 21 | ps.create(); 22 | ps.read(); 23 | ps.update(); 24 | ps.delete(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tutorial_i18n/src/main/java/carmelo/spring/introduccion/Introduccion.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import carmelo.spring.introduccion.service.SaludaService; 4 | import java.util.Locale; 5 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 | import org.springframework.context.support.AbstractApplicationContext; 7 | 8 | public class Introduccion { 9 | 10 | public static void main(String[] args) { 11 | 12 | AbstractApplicationContext ctx 13 | = new AnnotationConfigApplicationContext(SpringConfiguration.class); 14 | 15 | String msg_en = ctx.getMessage("title", null, Locale.ENGLISH); 16 | String msg_es = ctx.getMessage("title", null, new Locale("es")); 17 | 18 | System.out.println("English: " + msg_en); 19 | System.out.println("Español: " + msg_es); 20 | 21 | SaludaService ss = ctx.getBean(SaludaService.class); 22 | ss.saluda("carmelo", "marin"); 23 | 24 | ctx.close(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/src/main/java/carmelo/spring/controller/UsuarioController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import carmelo.spring.model.Usuario; 4 | import javax.validation.Valid; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.validation.BindingResult; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.servlet.ModelAndView; 10 | 11 | @Controller 12 | @RequestMapping("/user") 13 | public class UsuarioController { 14 | 15 | @RequestMapping("/form") 16 | public String showUserForm(Model model){ 17 | model.addAttribute("usuario", new Usuario()); 18 | return "userForm"; 19 | } 20 | 21 | @RequestMapping("/create") 22 | public ModelAndView createUser(@Valid Usuario user, BindingResult result) { 23 | ModelAndView model = new ModelAndView(); 24 | model.addObject("usuario", user); 25 | model.setViewName(result.hasErrors() ? "userForm" : "userReady"); 26 | return model; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_i18n/src/main/java/carmelo/spring/controller/UsuarioController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import carmelo.spring.model.Usuario; 4 | import javax.validation.Valid; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.validation.BindingResult; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.servlet.ModelAndView; 10 | 11 | @Controller 12 | @RequestMapping("/user") 13 | public class UsuarioController { 14 | 15 | @RequestMapping("/form") 16 | public String showUserForm(Model model){ 17 | model.addAttribute("usuario", new Usuario()); 18 | return "userForm"; 19 | } 20 | 21 | @RequestMapping("/create") 22 | public ModelAndView createUser(@Valid Usuario user, BindingResult result) { 23 | ModelAndView model = new ModelAndView(); 24 | model.addObject("usuario", user); 25 | model.setViewName(result.hasErrors() ? "userForm" : "userReady"); 26 | return model; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tutorial_jdbc_template/src/main/java/carmelo/spring/jdbc/model/Product.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc.model; 2 | 3 | public class Product { 4 | 5 | private Integer id; 6 | private String name; 7 | private Double price; 8 | 9 | public Product() { 10 | } 11 | 12 | public Product(Integer id, String name, Double price) { 13 | this.id = id; 14 | this.name = name; 15 | this.price = price; 16 | } 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | public Double getPrice() { 35 | return price; 36 | } 37 | 38 | public void setPrice(Double price) { 39 | this.price = price; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Product{" + "id=" + id + ", name=" + name + ", price=" + price + '}'; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/java/carmelo/spring/controller/UsuarioController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import carmelo.spring.model.Usuario; 4 | import javax.validation.Valid; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.validation.BindingResult; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.servlet.ModelAndView; 10 | 11 | @Controller 12 | @RequestMapping("/user") 13 | public class UsuarioController { 14 | 15 | @RequestMapping("/form") 16 | public String showUserForm(Model model){ 17 | model.addAttribute("usuario", new Usuario()); 18 | return "userForm"; 19 | } 20 | 21 | @RequestMapping("/create") 22 | public ModelAndView createUser(@Valid Usuario user, BindingResult result) { 23 | ModelAndView model = new ModelAndView(); 24 | model.addObject("usuario", user); 25 | model.setViewName(result.hasErrors() ? "userForm" : "userReady"); 26 | 27 | return model; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | dependency-reduced-pom.xml 8 | buildNumber.properties 9 | .mvn/timing.properties 10 | 11 | # ========================= 12 | # Operating System Files 13 | # ========================= 14 | 15 | # OSX 16 | # ========================= 17 | 18 | .DS_Store 19 | .AppleDouble 20 | .LSOverride 21 | 22 | # Thumbnails 23 | ._* 24 | 25 | # Files that might appear in the root of a volume 26 | .DocumentRevisions-V100 27 | .fseventsd 28 | .Spotlight-V100 29 | .TemporaryItems 30 | .Trashes 31 | .VolumeIcon.icns 32 | 33 | # Directories potentially created on remote AFP share 34 | .AppleDB 35 | .AppleDesktop 36 | Network Trash Folder 37 | Temporary Items 38 | .apdisk 39 | 40 | # Windows 41 | # ========================= 42 | 43 | # Windows image file caches 44 | Thumbs.db 45 | ehthumbs.db 46 | 47 | # Folder config file 48 | Desktop.ini 49 | 50 | # Recycle Bin used on file shares 51 | $RECYCLE.BIN/ 52 | 53 | # Windows Installer files 54 | *.cab 55 | *.msi 56 | *.msm 57 | *.msp 58 | 59 | # Windows shortcuts 60 | *.lnk 61 | -------------------------------------------------------------------------------- /tutorial_autowiring/src/main/java/carmelo/spring/autowiring/Autowiring.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.autowiring; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.support.AbstractApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | /** 8 | * 9 | * @author Carmelo Marin Abrego 10 | */ 11 | public class Autowiring { 12 | 13 | /** 14 | * @param args the command line arguments 15 | */ 16 | public static void main(String[] args) { 17 | 18 | //AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(SpringJavaConfig.class); 19 | AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("springXMLConfig.xml"); 20 | 21 | for (String bean_name : ctx.getBeanDefinitionNames()) { 22 | System.out.println(":: " + bean_name); 23 | } 24 | 25 | EmpleadoService es = ctx.getBean("empleadoService", EmpleadoService.class); 26 | 27 | System.out.println("EDao: " + ((EmpleadoServiceImpl)es).getEmpleadoDao()); 28 | 29 | ctx.close(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /tutorial_beans/src/main/java/carmelo/spring/introduccion/Introduccion.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 4 | import org.springframework.context.support.AbstractApplicationContext; 5 | import org.springframework.context.support.ClassPathXmlApplicationContext; 6 | 7 | public class Introduccion { 8 | 9 | public static void main(String[] args) { 10 | 11 | // configuracion con archivo XML 12 | AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("springXMLConfig.xml"); 13 | 14 | // configuracion con codigo java 15 | // AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfiguration.class); 16 | 17 | for (String bean_name : ctx.getBeanDefinitionNames()) { 18 | System.out.println(":: " + bean_name); 19 | } 20 | 21 | // HelloService saluda = ctx.getBean("saludaService", HelloService.class); 22 | // saluda.saludar(); 23 | 24 | // System.out.println(ctx.getBean("one", ClientService.class)); 25 | 26 | ctx.close(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/webapp/WEB-INF/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Spring Thymeleaf 6 | 7 | 8 | 9 |

10 | 11 | 12 | 13 | 21 | 22 | 27 | 28 | 29 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/java/carmelo/spring/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import carmelo.spring.model.Customer; 4 | import carmelo.spring.service.CustomerService; 5 | import java.util.List; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.ModelAttribute; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | @Controller 13 | public class CustomerController { 14 | 15 | @Autowired 16 | private CustomerService cs; 17 | 18 | @ModelAttribute("customerList") 19 | public List getCustomerList() { 20 | return cs.findAll(); 21 | } 22 | 23 | @RequestMapping("/") 24 | public String verTodos(Model model) { 25 | return "customer"; 26 | } 27 | 28 | @RequestMapping("/pdf") 29 | public String generarPdf(Model model) { 30 | return "pdfView"; 31 | } 32 | 33 | @RequestMapping("/xls") 34 | public String generarXls(Model model) { 35 | return "xlsView"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/java/carmelo/spring/controller/HomeController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import carmelo.spring.model.Tipo; 4 | import carmelo.spring.model.Usuario; 5 | import java.time.LocalDate; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.ModelAttribute; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | @Controller 14 | public class HomeController { 15 | 16 | @ModelAttribute("usuarios") 17 | public List getUserList() { 18 | return Arrays.asList( 19 | new Usuario("Juan", "Perez", "jp@gmail.com", "1a", 20, true, Tipo.Administrador), 20 | new Usuario("Maria", "Lopez", "ml@gmail.com", "1b", 21, false, Tipo.Estandar), 21 | new Usuario("Beto", "Luna", "bluna@gmail.com", "1c", 20, true, Tipo.Anonimo) 22 | ); 23 | } 24 | 25 | @RequestMapping(value = {"/", "/home"}) 26 | public String viewHomePage(Model model) { 27 | model.addAttribute("fecha", LocalDate.now()); 28 | return "home"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tutorial_properties/src/main/resources/springXMLConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/java/carmelo/spring/report/DynamicReportView.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.report; 2 | 3 | import java.util.Collection; 4 | import java.util.Map; 5 | import net.sf.jasperreports.engine.JRDataSource; 6 | import net.sf.jasperreports.engine.JasperFillManager; 7 | import net.sf.jasperreports.engine.JasperPrint; 8 | import net.sf.jasperreports.engine.JasperReport; 9 | import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; 10 | import org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView; 11 | 12 | public class DynamicReportView extends JasperReportsMultiFormatView { 13 | 14 | @Override 15 | protected JasperReport loadReport() { 16 | return null; 17 | } 18 | 19 | @Override 20 | protected JasperPrint fillReport(Map model) throws Exception { 21 | 22 | JRDataSource ds = new JRBeanCollectionDataSource((Collection) model.get("datasource")); 23 | ReportGenerator rg = (ReportGenerator) model.get("generator"); 24 | 25 | JasperReport jr = rg.generateReport(model); 26 | JasperPrint jp = JasperFillManager.fillReport(jr, model, ds); 27 | 28 | return jp; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /tutorial_springboot-social-twitter/src/main/resources/templates/tweetsPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spring Twitter 5 | 17 | 18 | 19 | 20 |

Hola, Usuario

21 | 22 |

Tweets List

23 | 24 |
    25 |
  • 26 |
    27 | 28 | Username 29 |

    Tweet

    30 |
    31 |
  • 32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /tutorial_webmvc_anotaciones/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | springmvc 7 | 8 | org.springframework.web.servlet.DispatcherServlet 9 | 10 | 11 | contextClass 12 | 13 | org.springframework.web.context.support.AnnotationConfigWebApplicationContext 14 | 15 | 16 | 17 | contextConfigLocation 18 | 19 | carmelo.spring.config.AppConfig 20 | 21 | 22 | 1 23 | 24 | 25 | 26 | springmvc 27 | / 28 | 29 | 30 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/src/main/java/carmelo/spring/config/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import org.springframework.context.MessageSource; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.support.ResourceBundleMessageSource; 8 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 9 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 10 | 11 | @EnableWebMvc 12 | @Configuration 13 | @ComponentScan(basePackages = {"carmelo.spring.controller"}) 14 | public class WebAppConfig { 15 | 16 | @Bean 17 | public InternalResourceViewResolver getInternalResourceViewResolver() { 18 | InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 19 | resolver.setPrefix("/WEB-INF/views/"); 20 | resolver.setSuffix(".jsp"); 21 | return resolver; 22 | } 23 | 24 | @Bean 25 | public MessageSource messageSource() { 26 | ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); 27 | messageSource.setBasename("messages"); 28 | return messageSource; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/webapp/WEB-INF/views/product.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | 3 | 4 | 5 | Productos 6 | 7 | 8 |

Listado de Productos

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
NoNombrePrecio
${status.index + 1}${product.name}${product.price}Borrar
28 | 29 | 30 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/src/main/java/carmelo/spring/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import carmelo.spring.service.CustomerService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.servlet.ModelAndView; 10 | 11 | @Controller 12 | public class CustomerController { 13 | 14 | @Autowired 15 | private CustomerService customerService; 16 | 17 | @RequestMapping("/") 18 | public ModelAndView verInicio() { 19 | return new ModelAndView("customer"); 20 | } 21 | 22 | @RequestMapping("/report") 23 | public String verReporte(Model model, 24 | @RequestParam( 25 | name = "format", 26 | defaultValue = "pdf", 27 | required = false) String format) { 28 | 29 | model.addAttribute("format", format); 30 | model.addAttribute("datasource", customerService.findAll()); 31 | model.addAttribute("AUTOR", "Tutor de programacion"); 32 | 33 | return "customer_report"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/src/main/webapp/WEB-INF/templates/userForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Formulario Thymeleaf 5 | 6 | 7 | 8 | 15 | 16 | 17 |

Resgistro de Usuario:

18 | 19 |
20 | 21 |
22 |

23 |
24 | 25 | 26 | 27 | Nombre incorrecto 28 | 29 |
30 | 31 |
32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /tutorial_springboot-social-facebook/src/main/java/hello/HelloController.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.social.connect.ConnectionRepository; 5 | import org.springframework.social.facebook.api.Facebook; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | @Controller 11 | public class HelloController { 12 | 13 | private final Facebook facebook; 14 | private final ConnectionRepository connectionRepository; 15 | 16 | @Autowired 17 | public HelloController(Facebook facebook, ConnectionRepository connectionRepository) { 18 | this.facebook = facebook; 19 | this.connectionRepository = connectionRepository; 20 | } 21 | 22 | @RequestMapping("/") 23 | public String facebook(Model model) { 24 | 25 | if (connectionRepository.findPrimaryConnection(Facebook.class) == null) { 26 | return "redirect:/connect/facebook"; 27 | } 28 | 29 | model.addAttribute("perfil", facebook.userOperations().getUserProfile()); 30 | model.addAttribute("feed", facebook.feedOperations().getFeed()); 31 | 32 | return "hello"; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /tutorial_beans/src/main/java/carmelo/spring/introduccion/HelloServiceImpl.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.annotation.PreDestroy; 5 | import org.springframework.beans.factory.DisposableBean; 6 | import org.springframework.beans.factory.InitializingBean; 7 | import org.springframework.context.annotation.Scope; 8 | import org.springframework.stereotype.Service; 9 | 10 | //@Service(value="saludaService") 11 | //@Scope("prototype") 12 | public class HelloServiceImpl implements HelloService/*, InitializingBean, DisposableBean*/ { 13 | 14 | @Override 15 | public void saludar() { 16 | System.out.println("--- Hello Spring Framework ---"); 17 | } 18 | 19 | @PostConstruct 20 | public void initHello() { 21 | System.out.println("--- run init method ---"); 22 | } 23 | 24 | @PreDestroy 25 | public void destroyHello() { 26 | System.out.println("--- run destroy method ---"); 27 | } 28 | 29 | // @Override 30 | // public void afterPropertiesSet() throws Exception { 31 | // System.out.println("--- run init method ---"); 32 | // } 33 | // 34 | // @Override 35 | // public void destroy() throws Exception { 36 | // System.out.println("--- run destroy method ---"); 37 | // } 38 | } 39 | -------------------------------------------------------------------------------- /tutorial_spring_upload/src/main/java/carmelo/spring/config/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.config; 2 | 3 | import java.io.IOException; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.multipart.MultipartResolver; 8 | import org.springframework.web.multipart.commons.CommonsMultipartResolver; 9 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 10 | import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; 11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 12 | 13 | @EnableWebMvc 14 | @Configuration 15 | @ComponentScan("carmelo.spring.controller") 16 | public class WebAppConfig extends WebMvcConfigurerAdapter { 17 | 18 | @Bean 19 | public MultipartResolver multipartResolver() throws IOException { 20 | CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(); 21 | multipartResolver.setMaxUploadSize((1024 * 1024) * 10); 22 | return multipartResolver; 23 | } 24 | 25 | @Override 26 | public void configureViewResolvers(ViewResolverRegistry registry) { 27 | registry.jsp("/WEB-INF/views/", ".jsp"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tutorial_webmvc_resources/src/main/java/carmelo/spring/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.http.CacheControl; 7 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 8 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 9 | import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 11 | 12 | @Configuration 13 | @EnableWebMvc 14 | @ComponentScan(basePackages = {"carmelo.spring.controller"}) 15 | public class WebAppConfig extends WebMvcConfigurerAdapter{ 16 | 17 | 18 | @Override 19 | public void configureViewResolvers(ViewResolverRegistry registry) { 20 | registry.jsp("/WEB-INF/views/", ".jsp"); 21 | } 22 | 23 | @Override 24 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 25 | registry.addResourceHandler("/static/**") 26 | .addResourceLocations("/public/", "/webjars/") 27 | .setCacheControl(CacheControl.maxAge(2, TimeUnit.DAYS)) 28 | .resourceChain(true); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/webapp/WEB-INF/views/productform.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib uri="http://www.springframework.org/tags/form" prefix="mvc" %> 3 | 4 | 5 | 6 | 7 | Add Product 8 | 9 | 10 |

Agregar nuevo producto:

11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 |
ID
Nombre
Precio
27 | 28 |
31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /tutorial_mvc_custom-validator/tutorial_custom_validator/src/main/java/carmelo/spring/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.http.CacheControl; 7 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 8 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 9 | import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 11 | 12 | @Configuration 13 | @EnableWebMvc 14 | @ComponentScan(basePackages = {"carmelo.spring.controller"}) 15 | public class WebAppConfig extends WebMvcConfigurerAdapter{ 16 | 17 | @Override 18 | public void configureViewResolvers(ViewResolverRegistry registry) { 19 | registry.jsp("/WEB-INF/views/", ".jsp"); 20 | } 21 | 22 | @Override 23 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 24 | registry.addResourceHandler("/static/**") 25 | .addResourceLocations("/public/", "/webjars/") 26 | .setCacheControl(CacheControl.maxAge(2, TimeUnit.SECONDS)) 27 | .resourceChain(true); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tutorial_spring_data/src/main/java/carmelo/spring/data/SpringDataJpa.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.data; 2 | 3 | import carmelo.spring.data.model.Product; 4 | import java.sql.SQLException; 5 | import carmelo.spring.data.repository.ProductRepository; 6 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 7 | import org.springframework.context.support.AbstractApplicationContext; 8 | 9 | public class SpringDataJpa { 10 | 11 | public static void main(String[] args) throws SQLException { 12 | 13 | AbstractApplicationContext ctx 14 | = new AnnotationConfigApplicationContext(SpringConfiguration.class); 15 | 16 | ProductRepository pr = ctx.getBean(ProductRepository.class); 17 | 18 | // crear un nuevo producto 19 | Product p0 = new Product(); 20 | p0.setId(100L); 21 | p0.setName("Porotos"); 22 | p0.setPrice(2.50); 23 | 24 | // agregar un nuevo producto 25 | pr.save(p0); 26 | 27 | // listar todos los productos 28 | pr.findAll().forEach(System.out::println); 29 | 30 | // productos con precio mayor a B/ 100.00 31 | System.out.println("--- PRODUCTOS CON SOBREPRECIO ---"); 32 | pr.findByPriceGreaterThan(100.0).forEach(System.out::println); 33 | 34 | ctx.close(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/java/carmelo/spring/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.ViewResolver; 7 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 8 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 9 | import org.springframework.web.servlet.view.ResourceBundleViewResolver; 10 | 11 | @Configuration 12 | @EnableWebMvc 13 | @ComponentScan(basePackages = { 14 | "carmelo.spring.controller", 15 | "carmelo.spring.service"}) 16 | public class WebAppConfig { 17 | 18 | @Bean 19 | public ViewResolver resourceBundleViewResolver() { 20 | ResourceBundleViewResolver viewResolver = new ResourceBundleViewResolver(); 21 | viewResolver.setBasename("views"); 22 | viewResolver.setOrder(1); 23 | return viewResolver; 24 | } 25 | 26 | @Bean 27 | public ViewResolver internalResourceViewResolver() { 28 | InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 29 | resolver.setPrefix("/WEB-INF/views/"); 30 | resolver.setSuffix(".jsp"); 31 | resolver.setOrder(2); 32 | return resolver; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tutorial_springboot-social-twitter/src/main/java/hello/TwitterController.java: -------------------------------------------------------------------------------- 1 | package hello; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.social.connect.ConnectionRepository; 7 | import org.springframework.social.twitter.api.Tweet; 8 | import org.springframework.social.twitter.api.Twitter; 9 | import org.springframework.social.twitter.api.TwitterProfile; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.ui.Model; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | 14 | @Controller 15 | public class TwitterController { 16 | 17 | @Autowired 18 | private Twitter twitter; 19 | 20 | @Autowired 21 | private ConnectionRepository connectionRepository; 22 | 23 | @RequestMapping("/") 24 | public String tweets(Model model) { 25 | 26 | if (connectionRepository.findPrimaryConnection(Twitter.class) == null) { 27 | return "redirect:/connect/twitter"; 28 | } 29 | 30 | List tweets = twitter.timelineOperations().getHomeTimeline(); 31 | TwitterProfile profile = twitter.userOperations().getUserProfile(); 32 | 33 | model.addAttribute("tweets", tweets); 34 | model.addAttribute("profile", profile); 35 | 36 | return "tweetsPage"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tutorial_webmvc_json/src/main/java/carmelo/spring/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import carmelo.spring.model.Customer; 4 | import carmelo.spring.service.CustomerService; 5 | import com.fasterxml.jackson.annotation.JsonView; 6 | import java.util.List; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.MediaType; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | @Controller 15 | public class CustomerController { 16 | 17 | @Autowired 18 | private CustomerService cs; 19 | 20 | @RequestMapping(value = {"/", "/index"}) 21 | public String customerJsp(Model model) { 22 | model.addAttribute("customerList", cs.findAll()); 23 | return "customer"; 24 | } 25 | 26 | @ResponseBody 27 | @RequestMapping("/data") 28 | public List customerJson() { 29 | return cs.findAll(); 30 | } 31 | 32 | @RequestMapping(name = "/list") 33 | public String customerJsonList(Model model) { 34 | model.addAttribute(cs.findAll()); 35 | model.addAttribute(JsonView.class.getName(), Customer.TestView.class); 36 | return "jsonView"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /tutorial_jdbc/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_jdbc 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | org.springframework 17 | spring-jdbc 18 | 4.3.6.RELEASE 19 | 20 | 21 | org.hsqldb 22 | hsqldb 23 | 2.3.3 24 | 25 | 26 | 27 | 28 | UTF-8 29 | 1.8 30 | 1.8 31 | 32 | 33 | -------------------------------------------------------------------------------- /tutorial_hibernate_jpa/src/main/java/carmelo/spring/jpa/model/Product.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jpa.model; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | 8 | @Entity 9 | @Table(name = "PRODUCT") 10 | public class Product { 11 | 12 | @Id 13 | @Column(name = "ID") 14 | private Integer id; 15 | 16 | @Column(name = "NAME") 17 | private String name; 18 | 19 | @Column(name = "PRICE") 20 | private Double price; 21 | 22 | public Product() { 23 | } 24 | 25 | public Product(Integer id, String name, Double price) { 26 | this.id = id; 27 | this.name = name; 28 | this.price = price; 29 | } 30 | 31 | public Integer getId() { 32 | return id; 33 | } 34 | 35 | public void setId(Integer id) { 36 | this.id = id; 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public void setName(String name) { 44 | this.name = name; 45 | } 46 | 47 | public Double getPrice() { 48 | return price; 49 | } 50 | 51 | public void setPrice(Double price) { 52 | this.price = price; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return "Product{" + "id=" + id + ", name=" + name + ", price=" + price + '}'; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /tutorial_web_mvc/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_ViewResolver/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | true 17 | 18 | 19 | 20 | src/main/webapp/WEB-INF/views.xml 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_AOP_introduccion/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | tutor.programacion 7 | SpringAOP 8 | 1.0 9 | jar 10 | 11 | 12 | 13 | org.springframework 14 | spring-aop 15 | 4.3.8.RELEASE 16 | 17 | 18 | org.springframework 19 | spring-context 20 | 4.3.8.RELEASE 21 | 22 | 23 | org.aspectj 24 | aspectjweaver 25 | 1.8.10 26 | 27 | 28 | 29 | 30 | UTF-8 31 | 1.8 32 | 1.8 33 | 34 | -------------------------------------------------------------------------------- /tutorial_spring_upload/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_noxml/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_theme/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_properties/src/main/java/carmelo/spring/introduccion/SpringConfiguration.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.introduccion; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.FileReader; 5 | import java.io.IOException; 6 | import java.util.stream.Collectors; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.PropertySource; 11 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; 12 | import org.springframework.core.io.Resource; 13 | 14 | @Configuration 15 | @PropertySource("classpath:application.properties") 16 | public class SpringConfiguration { 17 | 18 | @Value("${autor}") 19 | private String mensaje; 20 | 21 | @Value("${classpath:web/index.html}") 22 | private Resource page; 23 | 24 | @Bean 25 | public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { 26 | return new PropertySourcesPlaceholderConfigurer(); 27 | } 28 | 29 | @Bean 30 | public HelloService saludaService() throws IOException { 31 | 32 | BufferedReader br = new BufferedReader(new FileReader(page.getFile())); 33 | String msg = br.lines().collect(Collectors.joining(System.lineSeparator())); 34 | 35 | return new HelloServiceImpl(msg); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /tutorial_webmvc_anotaciones/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_controller/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_validacion/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_form/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_webmvc_thymeleaf_i18n/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorial_jdbc_template/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_jdbc_template 6 | 1.0 7 | jar 8 | 9 | 10 | 11 | org.springframework 12 | spring-context 13 | 4.3.6.RELEASE 14 | 15 | 16 | org.springframework 17 | spring-jdbc 18 | 4.3.6.RELEASE 19 | 20 | 21 | org.hsqldb 22 | hsqldb 23 | 2.3.3 24 | runtime 25 | 26 | 27 | 28 | 29 | UTF-8 30 | 1.8 31 | 1.8 32 | 33 | 34 | -------------------------------------------------------------------------------- /tutorial_spring_querydsl/src/main/java/carmelo/spring/data/SpringDataJpa.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.data; 2 | 3 | import carmelo.spring.data.model.QProduct; 4 | import carmelo.spring.data.repository.ProductRepository; 5 | import com.querydsl.core.types.Predicate; 6 | import com.querydsl.core.types.dsl.BooleanExpression; 7 | import java.sql.SQLException; 8 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 9 | import org.springframework.context.support.AbstractApplicationContext; 10 | 11 | public class SpringDataJpa { 12 | 13 | public static void main(String[] args) throws SQLException { 14 | 15 | AbstractApplicationContext ctx 16 | = new AnnotationConfigApplicationContext(SpringConfiguration.class); 17 | 18 | ProductRepository pr = ctx.getBean(ProductRepository.class); 19 | 20 | QProduct qp = QProduct.product; 21 | 22 | BooleanExpression precio = qp.price.gt(100.0); 23 | BooleanExpression helado = qp.name.contains("Ice"); 24 | 25 | Predicate helados_caros = helado.and(precio); 26 | 27 | pr.findAll(helados_caros).forEach(System.out::println); 28 | 29 | // pr.findAll(qp.isNotNull(), qp.price.asc()) 30 | // .forEach(System.out::println); 31 | // 32 | // long count = pr.count(qp.price.between(50.0, 220.0)); 33 | // System.out.println("count: " + count); 34 | 35 | ctx.close(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/src/main/java/carmelo/spring/WebAppConfig.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring; 2 | 3 | import carmelo.spring.report.DynamicReportView; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.servlet.ViewResolver; 8 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 9 | import org.springframework.web.servlet.view.InternalResourceViewResolver; 10 | import org.springframework.web.servlet.view.jasperreports.JasperReportsViewResolver; 11 | 12 | @Configuration 13 | @EnableWebMvc 14 | @ComponentScan(basePackages = { 15 | "carmelo.spring.controller", 16 | "carmelo.spring.service"}) 17 | public class WebAppConfig { 18 | 19 | @Bean 20 | public ViewResolver reportViewResolver() { 21 | JasperReportsViewResolver resolver = new JasperReportsViewResolver(); 22 | resolver.setViewNames("*_DynamicReport"); 23 | resolver.setViewClass(DynamicReportView.class); 24 | resolver.setOrder(1); 25 | return resolver; 26 | } 27 | 28 | @Bean 29 | public ViewResolver jspViewResolver() { 30 | InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 31 | resolver.setPrefix("/WEB-INF/views/"); 32 | resolver.setSuffix(".jsp"); 33 | resolver.setOrder(2); 34 | return resolver; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tutorial_mvc_custom-validator/tutorial_custom_validator/src/main/java/carmelo/spring/model/Person.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.model; 2 | 3 | public class Person { 4 | 5 | private String nombre; 6 | private String apellido; 7 | private String correo; 8 | private String nacionalidad; 9 | private Integer edad; 10 | 11 | public String getNombre() { 12 | return nombre; 13 | } 14 | 15 | public void setNombre(String nombre) { 16 | this.nombre = nombre; 17 | } 18 | 19 | public String getApellido() { 20 | return apellido; 21 | } 22 | 23 | public void setApellido(String apellido) { 24 | this.apellido = apellido; 25 | } 26 | 27 | public String getCorreo() { 28 | return correo; 29 | } 30 | 31 | public void setCorreo(String correo) { 32 | this.correo = correo; 33 | } 34 | 35 | public String getNacionalidad() { 36 | return nacionalidad; 37 | } 38 | 39 | public void setNacionalidad(String nacionalidad) { 40 | this.nacionalidad = nacionalidad; 41 | } 42 | 43 | public void setEdad(Integer edad) { 44 | this.edad = edad; 45 | } 46 | 47 | public Integer getEdad() { 48 | return edad; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "Person{" + "nombre=" + nombre + ", apellido=" + apellido + ", correo=" + correo + ", nacionalidad=" + nacionalidad + ", edad=" + edad + '}'; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /tutorial_mybatis_spring/src/main/java/tutor/java/mybatisexample/data/Customer.java: -------------------------------------------------------------------------------- 1 | package tutor.java.mybatisexample.data; 2 | 3 | public class Customer { 4 | 5 | private Long id; 6 | private String firstname; 7 | private String lastname; 8 | private String street; 9 | private String city; 10 | 11 | public Long getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Long id) { 16 | this.id = id; 17 | } 18 | 19 | public String getFirstname() { 20 | return firstname; 21 | } 22 | 23 | public void setFirstname(String firstname) { 24 | this.firstname = firstname; 25 | } 26 | 27 | public String getLastname() { 28 | return lastname; 29 | } 30 | 31 | public void setLastname(String lastname) { 32 | this.lastname = lastname; 33 | } 34 | 35 | public String getStreet() { 36 | return street; 37 | } 38 | 39 | public void setStreet(String street) { 40 | this.street = street; 41 | } 42 | 43 | public String getCity() { 44 | return city; 45 | } 46 | 47 | public void setCity(String city) { 48 | this.city = city; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "Customer{" + "id=" + id 54 | + ", firstname=" + firstname 55 | + ", lastname=" + lastname 56 | + ", street=" + street 57 | + ", city=" + city + '}'; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /tutorial_hibernate_jpa/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO Customer VALUES(0,'Laura','Steel','429 Seventh Av.','Dallas'); 2 | INSERT INTO Product VALUES(0,'Iron Iron',54); 3 | INSERT INTO Customer VALUES(1,'Susanne','King','366 - 20th Ave.','Olten'); 4 | INSERT INTO Product VALUES(1,'Chair Shoe',248); 5 | INSERT INTO Customer VALUES(2,'Anne','Miller','20 Upland Pl.','Lyon'); 6 | INSERT INTO Product VALUES(2,'Telephone Clock',248); 7 | INSERT INTO Customer VALUES(3,'Michael','Clancy','542 Upland Pl.','San Francisco'); 8 | INSERT INTO Product VALUES(3,'Chair Chair',254); 9 | INSERT INTO Customer VALUES(4,'Sylvia','Ringer','365 College Av.','Dallas'); 10 | INSERT INTO Product VALUES(4,'Ice Tea Shoe',128); 11 | INSERT INTO Customer VALUES(5,'Laura','Miller','294 Seventh Av.','Paris'); 12 | INSERT INTO Product VALUES(5,'Clock Clock',236); 13 | INSERT INTO Customer VALUES(6,'Laura','White','506 Upland Pl.','Palo Alto'); 14 | INSERT INTO Product VALUES(6,'Ice Tea Chair',98); 15 | INSERT INTO Customer VALUES(7,'James','Peterson','231 Upland Pl.','San Francisco'); 16 | INSERT INTO Product VALUES(7,'Telephone Shoe',84); 17 | INSERT INTO Customer VALUES(8,'Andrew','Miller','288 - 20th Ave.','Seattle'); 18 | INSERT INTO Product VALUES(8,'Ice Tea Clock',226); 19 | INSERT INTO Customer VALUES(9,'James','Schneider','277 Seventh Av.','Berne'); 20 | INSERT INTO Product VALUES(9,'Clock Telephone',172); 21 | INSERT INTO Customer VALUES(10,'Anne','Fuller','135 Upland Pl.','Dallas'); 22 | INSERT INTO Product VALUES(10,'Telephone Ice Tea',204); -------------------------------------------------------------------------------- /tutorial_webmvc_controller/src/main/java/carmelo/spring/controller/VentasController.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | 10 | @Controller 11 | public class VentasController { 12 | 13 | @RequestMapping("/ventas") 14 | public String porVendedor( 15 | @RequestParam("nombre") String nombre, 16 | @RequestParam("mes") Integer mes, 17 | Model model) { 18 | 19 | model.addAttribute("vendedor", nombre); 20 | model.addAttribute("ventas", "Listado de ventas para el mes: " + mes); 21 | 22 | return "ventas"; 23 | } 24 | 25 | @ResponseBody 26 | @RequestMapping("/vendedor/{id}") 27 | public String vendedor(@PathVariable("id") Long id) { 28 | return "Buscar vendor con ID = " + id; 29 | } 30 | 31 | @ResponseBody 32 | @RequestMapping("/depto/{dep}/vendedor/{id}") 33 | public String departamentoVendedor( 34 | @PathVariable("id") Long id, 35 | @PathVariable("dep") String dep) { 36 | 37 | String res = "Este es el departamento de: %s, y el vendedor ID: %d"; 38 | 39 | return String.format(res, dep, id); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/src/main/resources/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO Customer VALUES(0,'Laura','Steel','429 Seventh Av.','Dallas'); 2 | INSERT INTO Product VALUES(0,'Iron Iron',54); 3 | INSERT INTO Customer VALUES(1,'Susanne','King','366 - 20th Ave.','Olten'); 4 | INSERT INTO Product VALUES(1,'Chair Shoe',248); 5 | INSERT INTO Customer VALUES(2,'Anne','Miller','20 Upland Pl.','Lyon'); 6 | INSERT INTO Product VALUES(2,'Telephone Clock',248); 7 | INSERT INTO Customer VALUES(3,'Michael','Clancy','542 Upland Pl.','San Francisco'); 8 | INSERT INTO Product VALUES(3,'Chair Chair',254); 9 | INSERT INTO Customer VALUES(4,'Sylvia','Ringer','365 College Av.','Dallas'); 10 | INSERT INTO Product VALUES(4,'Ice Tea Shoe',128); 11 | INSERT INTO Customer VALUES(5,'Laura','Miller','294 Seventh Av.','Paris'); 12 | INSERT INTO Product VALUES(5,'Clock Clock',236); 13 | INSERT INTO Customer VALUES(6,'Laura','White','506 Upland Pl.','Palo Alto'); 14 | INSERT INTO Product VALUES(6,'Ice Tea Chair',98); 15 | INSERT INTO Customer VALUES(7,'James','Peterson','231 Upland Pl.','San Francisco'); 16 | INSERT INTO Product VALUES(7,'Telephone Shoe',84); 17 | INSERT INTO Customer VALUES(8,'Andrew','Miller','288 - 20th Ave.','Seattle'); 18 | INSERT INTO Product VALUES(8,'Ice Tea Clock',226); 19 | INSERT INTO Customer VALUES(9,'James','Schneider','277 Seventh Av.','Berne'); 20 | INSERT INTO Product VALUES(9,'Clock Telephone',172); 21 | INSERT INTO Customer VALUES(10,'Anne','Fuller','135 Upland Pl.','Dallas'); 22 | INSERT INTO Product VALUES(10,'Telephone Ice Tea',204); -------------------------------------------------------------------------------- /tutorial_spring_data/src/main/resources/data/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO Customer VALUES(0,'Laura','Steel','429 Seventh Av.','Dallas'); 2 | INSERT INTO Product VALUES(0,'Iron Iron',54); 3 | INSERT INTO Customer VALUES(1,'Susanne','King','366 - 20th Ave.','Olten'); 4 | INSERT INTO Product VALUES(1,'Chair Shoe',248); 5 | INSERT INTO Customer VALUES(2,'Anne','Miller','20 Upland Pl.','Lyon'); 6 | INSERT INTO Product VALUES(2,'Telephone Clock',248); 7 | INSERT INTO Customer VALUES(3,'Michael','Clancy','542 Upland Pl.','San Francisco'); 8 | INSERT INTO Product VALUES(3,'Chair Chair',254); 9 | INSERT INTO Customer VALUES(4,'Sylvia','Ringer','365 College Av.','Dallas'); 10 | INSERT INTO Product VALUES(4,'Ice Tea Shoe',128); 11 | INSERT INTO Customer VALUES(5,'Laura','Miller','294 Seventh Av.','Paris'); 12 | INSERT INTO Product VALUES(5,'Clock Clock',236); 13 | INSERT INTO Customer VALUES(6,'Laura','White','506 Upland Pl.','Palo Alto'); 14 | INSERT INTO Product VALUES(6,'Ice Tea Chair',98); 15 | INSERT INTO Customer VALUES(7,'James','Peterson','231 Upland Pl.','San Francisco'); 16 | INSERT INTO Product VALUES(7,'Telephone Shoe',84); 17 | INSERT INTO Customer VALUES(8,'Andrew','Miller','288 - 20th Ave.','Seattle'); 18 | INSERT INTO Product VALUES(8,'Ice Tea Clock',226); 19 | INSERT INTO Customer VALUES(9,'James','Schneider','277 Seventh Av.','Berne'); 20 | INSERT INTO Product VALUES(9,'Clock Telephone',172); 21 | INSERT INTO Customer VALUES(10,'Anne','Fuller','135 Upland Pl.','Dallas'); 22 | INSERT INTO Product VALUES(10,'Telephone Ice Tea',204); -------------------------------------------------------------------------------- /tutorial_spring_querydsl/src/main/resources/data/data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO Customer VALUES(0,'Laura','Steel','429 Seventh Av.','Dallas'); 2 | INSERT INTO Product VALUES(0,'Iron Iron',54); 3 | INSERT INTO Customer VALUES(1,'Susanne','King','366 - 20th Ave.','Olten'); 4 | INSERT INTO Product VALUES(1,'Chair Shoe',248); 5 | INSERT INTO Customer VALUES(2,'Anne','Miller','20 Upland Pl.','Lyon'); 6 | INSERT INTO Product VALUES(2,'Telephone Clock',248); 7 | INSERT INTO Customer VALUES(3,'Michael','Clancy','542 Upland Pl.','San Francisco'); 8 | INSERT INTO Product VALUES(3,'Chair Chair',254); 9 | INSERT INTO Customer VALUES(4,'Sylvia','Ringer','365 College Av.','Dallas'); 10 | INSERT INTO Product VALUES(4,'Ice Tea Shoe',128); 11 | INSERT INTO Customer VALUES(5,'Laura','Miller','294 Seventh Av.','Paris'); 12 | INSERT INTO Product VALUES(5,'Clock Clock',236); 13 | INSERT INTO Customer VALUES(6,'Laura','White','506 Upland Pl.','Palo Alto'); 14 | INSERT INTO Product VALUES(6,'Ice Tea Chair',98); 15 | INSERT INTO Customer VALUES(7,'James','Peterson','231 Upland Pl.','San Francisco'); 16 | INSERT INTO Product VALUES(7,'Telephone Shoe',84); 17 | INSERT INTO Customer VALUES(8,'Andrew','Miller','288 - 20th Ave.','Seattle'); 18 | INSERT INTO Product VALUES(8,'Ice Tea Clock',226); 19 | INSERT INTO Customer VALUES(9,'James','Schneider','277 Seventh Av.','Berne'); 20 | INSERT INTO Product VALUES(9,'Clock Telephone',172); 21 | INSERT INTO Customer VALUES(10,'Anne','Fuller','135 Upland Pl.','Dallas'); 22 | INSERT INTO Product VALUES(10,'Telephone Ice Tea',204); -------------------------------------------------------------------------------- /tutorial_webmvc_json/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | true 17 | JSP 18 | 19 | 20 | 21 | src/main/webapp/WEB-INF/views.xml 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | JSP 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_report/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | JSP 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_views/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | JSP 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_resources/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | JSP 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_DynamicJasper/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | JSP 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_HandlerMapping/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | JSP 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_jdbc_template/src/main/java/carmelo/spring/jdbc/SpringJDBC.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.jdbc; 2 | 3 | import java.sql.SQLException; 4 | import carmelo.spring.jdbc.dao.ProductDao; 5 | import carmelo.spring.jdbc.model.Product; 6 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 7 | import org.springframework.context.support.AbstractApplicationContext; 8 | 9 | public class SpringJDBC { 10 | 11 | public static void main(String[] args) throws SQLException { 12 | 13 | AbstractApplicationContext ctx 14 | = new AnnotationConfigApplicationContext(SpringConfiguration.class); 15 | 16 | ProductDao product = ctx.getBean(ProductDao.class); 17 | 18 | System.out.println("Cantidad de productos: " + product.cantidad()); 19 | System.out.println("Producto con ID = 25: " + product.buscar(25)); 20 | 21 | // crear un nuevo producto 22 | Product p0 = new Product(111, "Computer", 800.25); 23 | 24 | // insertar nuevo producto 25 | product.insertar(p0); 26 | 27 | // bucar el producto con ID = 35 28 | Product p1 = product.buscar(35); 29 | p1.setName("Server Computer"); 30 | p1.setPrice(1001.25); 31 | 32 | // actualizar el producto con ID = 35 33 | product.actualizar(p1); 34 | 35 | // listar todos los productos 36 | product.todos().forEach(System.out::println); 37 | 38 | // eliminar el producto con ID = 111 39 | product.eliminar(p0.getId()); 40 | 41 | ctx.close(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tutorial_springboot-social-twitter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 4.0.0 8 | 9 | tutor.spring 10 | spring-social-twitter 11 | 1.0.0 12 | 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | 1.5.6.RELEASE 17 | 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-thymeleaf 24 | 25 | 26 | 27 | org.springframework.social 28 | spring-social-twitter 29 | 30 | 31 | 32 | 33 | 34 | 1.8 35 | 36 | 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-maven-plugin 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /tutorial_mvc_custom-validator/tutorial_custom_validator/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | src/main/webapp/WEB-INF/springmvc-servlet.xml 12 | 13 | 14 | 15 | 16 | 22 | true 23 | JSP 24 | 25 | 26 | -------------------------------------------------------------------------------- /tutorial_webmvc_pdf_xls/src/main/java/carmelo/spring/view/PdfView.java: -------------------------------------------------------------------------------- 1 | package carmelo.spring.view; 2 | 3 | import carmelo.spring.model.Customer; 4 | import com.lowagie.text.Document; 5 | import com.lowagie.text.pdf.PdfPTable; 6 | import com.lowagie.text.pdf.PdfWriter; 7 | import java.util.List; 8 | import java.util.Map; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import org.springframework.web.servlet.view.document.AbstractPdfView; 12 | 13 | public class PdfView extends AbstractPdfView { 14 | 15 | @Override 16 | protected void buildPdfDocument( 17 | Map model, 18 | Document document, 19 | PdfWriter writer, 20 | HttpServletRequest request, 21 | HttpServletResponse response) throws Exception { 22 | 23 | List customerList = (List) model.get("customerList"); 24 | 25 | PdfPTable table = new PdfPTable(5); 26 | 27 | table.addCell("ID"); 28 | table.addCell("First Name"); 29 | table.addCell("Last Name"); 30 | table.addCell("Street"); 31 | table.addCell("City"); 32 | 33 | customerList.forEach(customer -> { 34 | table.addCell(customer.getId().toString()); 35 | table.addCell(customer.getFirstName()); 36 | table.addCell(customer.getLastName()); 37 | table.addCell(customer.getStreet()); 38 | table.addCell(customer.getCity()); 39 | }); 40 | 41 | document.add(table); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tutorial_web_mvc/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | carmelo.spring 5 | tutorial_web_mvc 6 | war 7 | 1.0 8 | tutorial_web_mvc 9 | 10 | 11 | 4.3.7.RELEASE 12 | UTF-8 13 | 1.8 14 | 1.8 15 | 16 | 17 | 18 | 19 | org.springframework 20 | spring-webmvc 21 | ${spring.version} 22 | 23 | 24 | 25 | 26 | tutorial_web_mvc 27 | 28 | 29 | org.apache.maven.plugins 30 | maven-war-plugin 31 | 2.3 32 | 33 | false 34 | 35 | 36 | 37 | 38 | 39 | 40 | --------------------------------------------------------------------------------