Course Outline 227221

Download Report

Transcript Course Outline 227221

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
JSP
Controller
Spring
Model
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.
INSTALLATION GUIDE
INSTALLATION GUIDE
INSTALLATION GUIDE
gradle build
INSTALLATION GUIDE
TEST JAVA APPLICATION
gradle run
DEPENDENCY INJECTION
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
GRADLE WEB APPLICATION
GRADLE WEB APPLICATION
GRADLE WEB APPLICATION
build.gradle
buildscript {
repositories {
repositories {
mavenCentral()
mavenCentral()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/milestone" }
}
}
dependencies {
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.10.RELEASE")
compile("org.springframework.boot:spring-boot-starter-web")
}
}
apply plugin: 'java'
apply plugin: 'spring-boot‘
apply plugin: ‘war’
jar {
baseName = 'myproject'
version = '0.0.1-SNAPSHOT'
}
testCompile("org.springframework.boot:spring-boot-starter-test")
}
GRADLE WEB APPLICATION
SampleController
package com.spring;
@RequestMapping("/")
@ResponseBody
import org.springframework.boot.*;
String home() {
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
public class SampleController {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception {
SpringApplication
spring = new SpringApplication(SampleController.class);
SpringApplication.run(SampleController.class, args);
spring.setShowBanner(false);
}
spring.run(args);
}
}
GRADLE WEB APPLICATION
export spring-boot to exist tomcat or JEE Server