Upload
kenu-heo
View
18.693
Download
3
Embed Size (px)
DESCRIPTION
2시간 만에 시작하는 스프링 프레임워크 3.x
Citation preview
토픽
• 스프링 프레임워크 개요
• 스프링 프레임워크로 시작하는 웹 개발
• Maven 빌드 도구의 이해
• 스프링 개발환경과 DB서버
• 스프링 모듈 소개
스프링 프레임워크 개요
• JavaEE development without EJB
• 2004
• 로드 존슨
프레임워크 기본 컨셉
• Inversion of Control / Dependency Injection
• Aspect Oriented Programming
• Portable Service Abstractions
http://www.springframework.net/docs/1.3.0/reference/html/psa-intro.html
Plain Object
• POJO; Plain Old Java Object
• not like Servlet
• extends javax.servlet.http.HttpServlet
IoC / DI
• 사용할 객체를 외부에서 주입
• 생성자의 인자 또는 setter 메소스 이용
• Strategy Pattern
IoC 장점
• 플러그인 만들기 좋음
• Interface 준수
• 테스트 객체로, 주입 객체 바꿔치기
IoC/DI
egovframe 실행환경교재(01.공통기반).pdf 33p
PSA
• 포터블 서비스 추상화
• 환경에 종속되지 않도록 유연한 추상 계층
AOP
• 로깅, 트랜잭션과 같이 산재된 코드 모듈화
• Advice
• Pointcut
• 스프링 Advisor
스프링 아키텍처
J2EE����������� ������������������ architecture
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Overview7.html
J2EE����������� ������������������ without����������� ������������������ EJB
http://jangsunjin.tistory.com/166
스프링 아키텍처
모듈과 특징• 코어 컨테이너:
Core, Beans, Context, Expression Language
• 데이터 접근/통합: JDBC, ORM, OXM, JMS, 트랜잭션 모듈
• 웹: 웹, 웹-서블릿, 웹-스트러츠, 웹-포틀릿
• AOP와 인스트루먼테이션: 코드의 반복적인 중복을 일원화, 클래스로딩 제어
• 테스트: JUnit과 TestNG
핵심 효과Modularity
Productivity
Portability
Testability
POJO 심플, 명료, 모듈
70% 개발자 보고, 시간 단축
톰캣, JavaEE, 클라우드 플랫폼
유닛, 통합 테스트 쉽게
http://www.springsource.org/features
More Projects
• Spring AMQP
• Spring for Android
• Spring Batch
• Spring Data
• Spring Framework
• Spring Gemfire
• Spring Integration
• Spring Mobile
• Spring .NET
• Spring Roo
• Spring Security
• Spring Social
• Spring Web Flow
• Spring Web Services
소스 아키텍처
SpringFramework Layers
ref:����������� ������������������ http://www.javajigi.net/display/OSS/Spring_MVC_2
Dom
ain
Mod
el
User Interface (View)
Web (Controller)
Service
Persistence (DAO)
Request����������� ������������������ LifeCycle
http://www.javajigi.net/pages/viewpage.action?pageId=19398699
코드 네비게이션
1. URL����������� ������������������ mapping
2. Controller
3. Service
4. DAO
5. SQL
SearchFind SelectionOpen ResourceOpen DefinitionHierarchyBack
ctrl+Hctrl+Kctrl+shift+RF3ctrl+Talt+←
개발 코드 구성
• Maven Style• src/main/java/
• /resources/
• /webapp/
• /test/java/
• /resources/
• target/ (.gitignore)
• pom.xml
STS
• 입문할 때는 Spring Tools Suite 추천
• http://www.springsource.org/sts
• Maven, Git
가져오기
• https://github.com/kenu/egov
• zip download
• File > Import... > zip
• Existing Projects > archive file
• Customized Local Environment
Run Sample
• Project > Clean...
• Run as > Run on Server
새 프로젝트
Spring Template Project
Template Selection
Spring MVC Project
Template Download
Project Settings
프로젝트 구성
utf-8
utf-8
프로젝트 전체 인코딩 이클립스 전체 인코딩
버전
버전
http://open.egovframe.go.kr/projects/information/filearchive/5265
Maven 빌드 도구
Java Compile 단점
• 패키지별로 따로 지정
• make 또는 compile.bat
• 클래스패스 설정 어려움
ANT
• Another Neat Tool http://ant.apache.org
• build.xml
• project > targets > tasks
• properties ${base.dir}
Maven 빌드 도구• Convention over Configuration
• ANT의 자유로운 빌드 설정과 차별
• Jar 의존성 관리
• 버전 명시, 프로젝트별 중복 jar 관리
• 플러그인 관리
• 이클립스, 톰캣, Jetty 등의 연계 플러그인
Quick Start
•mvn --version
•mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
Quick Start #2 pom.xml
my-app|-- pom.xml`-- src |-- main | `-- java | `-- com | `-- mycompany | `-- app | `-- App.java `-- test `-- java `-- com `-- mycompany `-- app `-- AppTest.java
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging>
<name>Maven Quick Start Archetype</name> <url>http://maven.apache.org</url>
<dependencies>
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies></project>
Build Project
•mvn package
•package is a phase
•페이즈는 연속적인 작업들
mvn compile이면1. validate2. generate-sources3. process-sources4. generate-resources5. process-resources6. compile
• compile 까지의 페이즈를 순서대로 수행
Maven goal
• archetype:generate
• archetype: is the plugin
• archetype:generate is a goal
• plugin은 goal 모음집
•예) eclipse:eclipse, tomcat:run
Maven phases
• validate
• compile
• test
• package
• integration-test
• verify
• install
• deploy
• clean
• site
target/
• java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
• Hello World!
m2eclipse
• eclipse plugin
• little buggy
Deployment Assembly
Nexus
http://cwgkorea.net/zbxe/cwg_consensus/44551����������� ������������������
without
Intranet Internet
Dev����������� ������������������ A
Dev����������� ������������������ B
Central
with
Intranet Internet
Dev����������� ������������������ A
Dev����������� ������������������ B
Nexus Central
settings.xml
• ~/.m2/settings.xml <settings> <mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf>
<url>http://192.168.0.8:7070/nexus/content/groups/public</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles></settings>
관련����������� ������������������ 리소스
•자바지기����������� ������������������ 위키
⁻http://www.javajigi.net/display/SFL/Home
•전자정부표준����������� ������������������ 프레임워크
⁻http://www.egovframe.go.kr/cop/bbs/selectBoardList.do?menu=2&submenu=2&bbsId=BBSMSTR_000000000002
⁻http://open.egovframe.go.kr/egov/download.php
• Spring����������� ������������������ 3����������� ������������������ Tutorial:����������� ������������������ Setting����������� ������������������ Up����������� ������������������ &����������� ������������������ Configuring����������� ������������������ The����������� ������������������ Environment����������� ������������������ By����������� ������������������ Jason����������� ������������������ Tee
⁻http://www.theserverside.com/tutorial/Spring-30-Tutorial-Setting-Up-Configuring-The-Environment
jPetStore Sample
• git svn clone https://src.springframework.org/svn/spring-samples/jpetstore/trunk
Toby Spring 3.1
• 2부는 제공된 코드와 함께
• 1부, 2부 CD는 동일
• https://github.com/kenu/tobyspring31
EgovFrame
• http://www.egovframe.go.kr
• 실행환경(스프링 3.0.5 기반)
• egovframe 2.0, 2.5
• 개발 위키 추천
• 오픈커뮤니티 Q&A 활용
• http://open.egovframe.go.kr
KSUG
• Korea Spring User Group
• http://www.ksug.org
• 구글그룹스 메일링 기반
• 개발 전문가들 눈팅
Q&A
감사합니다