SlideShare a Scribd company logo
Spring JavaConfig
Hibernate, Spring MVC
Key word
• Above Serlvet 3.0
• Hibernate basic
• Spring MVC
• Gradle
Overview
Web
browser
RDBMS
HSQLDB
<<실행환경>>
Web 컨테이너 Tomcat
<<Presentation>>
Jsp,jstl,bootstrap
Spring
Controller
UrlBasedView
Resolver
Domain Model
(entity)
Spring IOC
<<DataSource>>
DAO
Service
Context
WebInitializer
• Replace web.xml
• set root Context, servlet mapping
WebInitializer
• @Override
• protected Class<?>[] getServletConfigClasses() {
• return new Class[]{WebConfig.class}
• @Override
• protected String[] getServletMappings() {
• return new String[]{"/"};
• }
webConfig set index.html
• @Bean
• public UrlBasedViewResolver setupViewResolver() {
• UrlBasedViewResolver resolver = new UrlBasedViewResolver();
• resolver.setPrefix("/WEB-INF/views/");
• resolver.setSuffix(".jsp");
• resolver.setViewClass(JstlView.class);
• return resolver;
• }
webConfig set index.html 2
• 기본 페이지처럼 로직이 필요없는 경우에는 별도의 컨트롤러를 생성하지
않고 처리가능
• @Override
• public void
addViewControllers( org.springframework.web.servlet.config.annotation.Vie
wControllerRegistry registry){
registry.addViewController("/").setViewName("home");
}
•
정적 리소스(css,js,img) 등록처리
• @Override
• public void addResourceHandlers( ResourceHandlerRegistry
registry){
• registry.addResourceHandler("/resources/**")
• .addResourceLocations("/WEB-INF/resources/");
• }
정적 리소스(css,js,img) 등록처리
• <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
• <c:url value=“/resources/xxx.js”>
디폴트 서블릿 설정 등록
• DispatachServlet이 처리할 수 없는 나머지 요청을 기본 서블릿 설정으로 처
리
• @Override
• public void
configureDefaultServletHandling(DefaultServletHandlerConfigurer
configurer) {
• configurer.enable();
• }
Hibernate Config #1
WebInitializer
protected Class<?>[] getRootConfigClasses() {
• return new Class[]{DbConfig.class};
• }
Hibernate Config #2
• Hibernate property
• hibernate.dialect=org.hibernate.dialect.HSQLDialect 사용할 DB dialect
• hibernate.show_sql=true
• hibernate.format_sql=false
• hibernate.hbm2ddl.auto=create-drop
• entitymanager.packages.to.scan=entity POJO 패키지 위치
Hibernate Config #3
• Hibernate SessionFactory 설정
• @Bean
• public LocalSessionFactoryBean sessionFactory() {
• LocalSessionFactoryBean생성
• dataSource, hibernate property setting
• Scan할 패키지 등록
• }
Hibernate Config #4
• Transaction 설정
• @Bean
• public HibernateTransactionManager transactionManager() {
• HibernateTransactionManager transactionManager = new
HibernateTransactionManager();
• transactionManager.setSessionFactory(sessionFactory().getObject());
• return transactionManager;
• }
HSQLDB 설정
• db.driver =org.hsqldb.jdbc.JDBCDriver
• db.url = jdbc:hsqldb:mem:spring
• db.username = sa
• db.password=
Entity설정
• @Entity
• Class명과 table이 다른 경우 @Table( name =“테이블명”)
Crud #1 현재 세션 획득
• @Autowired
• private SessionFactory sessionFactory;
• private Session getCurrentSession() {
• return sessionFactory.getCurrentSession();
• }
Crud #2 Create
• getCurrentSession().save( Entity Object );
Crud #3 Update
Id값을 이용해서 목록에서 Update할 객체정보 획득
UpdateInstance = getCurrentSession().get(EntityClass, id);
Update
• getCurrentSession().update(UpdateInstance );
Crud #4 delete
• deleteInstance= getCurrentSession().get(EntityClass, id);
• getCurrentSession().delete(deleteInstance);
목록 조회
• getCurrentSession().createQuery("from 테이블명").list();
Rest API 설정 #1
설정등록
• @Override
• protected Class<?>[] getServletConfigClasses() {
• return new Class[]{WebConfig.class, RestConfig.class};
• }
Rest API 설정 #2
• Jason Converter 등록
• public void
configureMessageConverters(List<HttpMessageConverter<?>>
converters){
• converters.add(mappingJackson2HttpMessageConverter());
• }
Rest Controller
• ResponseBody사용
• @RequestMapping(method = RequestMethod.GET)
• @ResponseBody
• public List<Team> getList(){
• 결과 반환
• }
Source Repository
• https://github.com/sjyun/gradlespring

More Related Content

PPTX
MyBatis
ODP
Indexed db
PDF
Simple REST with Dropwizard
PDF
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
PPT
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
PDF
Dropwizard
PDF
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
PDF
Google App Engine Developer - Day4
MyBatis
Indexed db
Simple REST with Dropwizard
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
Dropwizard
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
Google App Engine Developer - Day4

What's hot (20)

PDF
Drupal 8: Fields reborn
PDF
Core Data with multiple managed object contexts
PDF
NoSQL and JavaScript: a Love Story
PDF
Nuxeo - OpenSocial
KEY
iOSDevCamp 2011 Core Data
PDF
ERGroupware
PPTX
Entity Framework Core & Micro-Orms with Asp.Net Core
PPTX
Java Microservices with DropWizard
PDF
Adventures in Multithreaded Core Data
PPTX
Academy PRO: ASP .NET Core
PDF
Spring4 whats up doc?
PDF
Dropwizard
PPT
jclouds overview
PDF
Webinar: MongoDB Persistence with Java and Morphia
PDF
HeadCouch - CouchDB PHP Client
PDF
Create a Core Data Observer in 10mins
PPTX
Test and profile your Windows Phone 8 App
PPTX
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
PPTX
EPAM IT WEEK: AEM & TDD. It's so boring...
PPTX
Indexing and Query Optimisation
Drupal 8: Fields reborn
Core Data with multiple managed object contexts
NoSQL and JavaScript: a Love Story
Nuxeo - OpenSocial
iOSDevCamp 2011 Core Data
ERGroupware
Entity Framework Core & Micro-Orms with Asp.Net Core
Java Microservices with DropWizard
Adventures in Multithreaded Core Data
Academy PRO: ASP .NET Core
Spring4 whats up doc?
Dropwizard
jclouds overview
Webinar: MongoDB Persistence with Java and Morphia
HeadCouch - CouchDB PHP Client
Create a Core Data Observer in 10mins
Test and profile your Windows Phone 8 App
Azure Table Storage: The Good, the Bad, the Ugly (full talk)
EPAM IT WEEK: AEM & TDD. It's so boring...
Indexing and Query Optimisation
Ad

Similar to Spring java config (20)

PDF
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
PDF
spring3.2 java config Servler3
PDF
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
PPTX
비동기 회고 발표자료
PPTX
SpringBoot with MyBatis, Flyway, QueryDSL
PDF
Java/Spring과 Node.js의공존
PPT
Daejeon IT Developer Conference Web Service Practice
PDF
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
PDF
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...
PDF
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
PPTX
Spring data jpa simple example_스프링학원/자바학원추천/구로IT학원/자바학원
PDF
테크톡1 by roach: Spring Interceptor
PDF
Spring framework 4.x
PDF
[Spring Camp 2013] Java Configuration 없인 못살아!
PPTX
Java EE7
PPTX
Jersey framework
PPTX
What is persistence in java
PPTX
Spring MVC 5 & Hibernate 5 Integration
PPTX
Hibernate
PDF
SpringOnePlatform2017 recap
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
spring3.2 java config Servler3
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
비동기 회고 발표자료
SpringBoot with MyBatis, Flyway, QueryDSL
Java/Spring과 Node.js의공존
Daejeon IT Developer Conference Web Service Practice
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#34.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자교육,국...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
Spring data jpa simple example_스프링학원/자바학원추천/구로IT학원/자바학원
테크톡1 by roach: Spring Interceptor
Spring framework 4.x
[Spring Camp 2013] Java Configuration 없인 못살아!
Java EE7
Jersey framework
What is persistence in java
Spring MVC 5 & Hibernate 5 Integration
Hibernate
SpringOnePlatform2017 recap
Ad

More from Sukjin Yun (20)

PDF
동영상입문
PDF
Enterprise Java web Deployment Strategy
PDF
Geb quick start
PDF
BDD with Spock
PDF
Scala quick start
PPTX
Design pattern 옵저버
PDF
docker_quick_start
PDF
Rabbitmq install한글
PPT
Servlet3
PDF
Weblogic install
PDF
무료로 워드프레스시작하기
PDF
Start groovy
PDF
Pygame
PDF
Annotation
PDF
마리아Db
PDF
Intellij java
PDF
Ldap serise v1
PDF
Android studio
PDF
20130709 gradle
PDF
Servlet design pattern
동영상입문
Enterprise Java web Deployment Strategy
Geb quick start
BDD with Spock
Scala quick start
Design pattern 옵저버
docker_quick_start
Rabbitmq install한글
Servlet3
Weblogic install
무료로 워드프레스시작하기
Start groovy
Pygame
Annotation
마리아Db
Intellij java
Ldap serise v1
Android studio
20130709 gradle
Servlet design pattern

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPT
Mechanical Engineering MATERIALS Selection
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
composite construction of structures.pdf
PPT
Project quality management in manufacturing
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Digital Logic Computer Design lecture notes
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
DOCX
573137875-Attendance-Management-System-original
PPTX
Construction Project Organization Group 2.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
PPT on Performance Review to get promotions
CYBER-CRIMES AND SECURITY A guide to understanding
Mechanical Engineering MATERIALS Selection
OOP with Java - Java Introduction (Basics)
Automation-in-Manufacturing-Chapter-Introduction.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CH1 Production IntroductoryConcepts.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
composite construction of structures.pdf
Project quality management in manufacturing
Model Code of Practice - Construction Work - 21102022 .pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Digital Logic Computer Design lecture notes
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
573137875-Attendance-Management-System-original
Construction Project Organization Group 2.pptx
Foundation to blockchain - A guide to Blockchain Tech
PPT on Performance Review to get promotions

Spring java config