CHAPTER 4 SPRING FRAMEWORK Wattanapong suttapak, Software Engineering, school of Information communication Technology, university of phayao
จุดประสงค์การเรียนรู้ ตั้งค่า spring framework เพิ่ม ลบ แก้ไข ค้นหา ข้อมูลภายในตารางของ ฐานข้อมูลโดยใช้ spring framework ได้
SPRING FRAMEWORK what is spring framework? The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.
SPRING FRAMEWORK
ARCHITECTURAL CONCEPT :: 3 TIER 3 tier - presentation tier - business, domain logic, middle tier - data tier View Controller Model JSP Spring Hibernate
SPRING FRAMEWORK useful 1. application developer Make a Java method execute in a database transaction without having to deal with transaction APIs. Dependency Injection and Inversion of Control Aspect-Oriented Programming(AOP) Spring MVC web application and RESTful web service framework Foundation support JDBC, JPA, JMA, JMS, Hibernate Framework
DEPENDENCY INJECTION setWriter(obj) NiceWriter obj; IWriter obj;
DEPENDENCY INJECTION META-INF/beans.xml Main.java
SPRING FRAMEWORK prerequisite - Eclipse - Maven or Gradle
GRADLE WHAT IS GRADLE? Gradle is an open source build automation system. Gradle can automate the building, testing, publishing, deployment and more of software packages or other types of projects such as generated static websites, generated documentation or indeed anything else. Gradle combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build. Powered by Build Programming Language, Gradle is concise yet expressive.AntMaven
INSTALLATION GUIDE
gradle build
INSTALLATION GUIDE
TEST JAVA APPLICATION gradle run
DEPENDENCY INJECTION
gradle clean gradle build gradle run
GRADLE WEB APPLICATION create java dynamic website convert java web to gradle reconvert folder src\main\... to java build path
GRADLE WEB APPLICATION
build.gradle buildscript { repositories { mavenCentral() maven { url " } maven { url " } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin: RELEASE") } apply plugin: 'java' apply plugin: 'spring-boot‘ apply plugin: ‘war’ jar { baseName = 'myproject' version = '0.0.1-SNAPSHOT' } repositories { mavenCentral() maven { url " } maven { url " } } dependencies { compile("org.springframework.boot:spring-boot-starter-web") testCompile("org.springframework.boot:spring-boot-starter-test") }
GRADLE WEB APPLICATION SampleController package com.spring; import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; import org.springframework.stereotype.*; public class String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(SampleController.class, args); } public static void main(String[] args) throws Exception { SpringApplication spring = new SpringApplication(SampleController.class); spring.setShowBanner(false); spring.run(args); }
GRADLE WEB APPLICATION export spring-boot to exist tomcat or JEE Server