introduction to spring boot
TRANSCRIPT
![Page 2: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/2.jpg)
Before we startA task for you – time 15 minutesDevelop a web application which reads Employee information from MySQL DB and print on the screen. You need to use Spring and Hibenate(JPA). It should run in any web container.
![Page 3: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/3.jpg)
List out the challenges you have faced while setting up the env.
1) Download and set up a server (e.g. Tomcat)2) Download and install a DB3) Download required Spring jars4) Download Hibernate jar compatible with the Spring version5) Download jar for MySQL driver 6) Setting up web.xml to use spring MVC7) Anything I left ???
Before we start
![Page 4: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/4.jpg)
Why Spring Boot• Provides a radically faster and widely accessible ‘getting started’
experience for all Spring development• No clumsy XML Configuration by developers• Provide opinionated ‘starter’ POMs to simplify your Maven configuration• Uses project management tool such as MAVEN or GRADLE• Helps fast development and production ready code• Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)• In memory DB
![Page 5: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/5.jpg)
Documentationhttp://docs.spring.io/spring-boot/docs/current/reference/html/index.html
![Page 6: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/6.jpg)
System Requirement Spring Boot 1.4.2.RELEASE
• Apache Maven
• Java 7 +
![Page 8: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/8.jpg)
Folder Structure to be followed
![Page 9: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/9.jpg)
Understanding pom.xml
![Page 10: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/10.jpg)
Build runnable jar
![Page 11: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/11.jpg)
First Java Program for spring boot
![Page 12: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/12.jpg)
Running the application> mvn spring-boot:run
![Page 13: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/13.jpg)
Devtools• Automatic Restart• LiveReload• Remote Debug Tunneling• Remote Update and Restart
Details at:http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html
![Page 14: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/14.jpg)
Spring Tool Suite (sts)Download https://spring.io/tools/sts/all
![Page 15: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/15.jpg)
Spring Web & MVC
application.properties
pom.xml
![Page 16: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/16.jpg)
Without application.properties
![Page 17: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/17.jpg)
Runnable war1) In Main java file:
1.1 extend : org.springframework.boot.web.support.SpringBootServletInitializer1.2 override the method:
@Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(MyApplication.class); }
1.3 No need of main() method.
2) In pom.xml1.1 Change the packing to war as:
<packaging>war</packaging>3) Use command: mvn clean package
4) In target, rename the war<context root> as you want, deploy in tomcat and access with <context root>/<request mapping>
![Page 18: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/18.jpg)
MySQL & jdbcpom.xml
spring.datasource.jndi-name=java:jboss/datasources/customers - For JNDI Datasource
![Page 19: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/19.jpg)
MySQL & jdbc
![Page 20: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/20.jpg)
JPA in Spring Boot
![Page 21: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/21.jpg)
JPA in Spring Boot
![Page 22: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/22.jpg)
JPA in Spring Boot
![Page 23: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/23.jpg)
JPA in Spring Boot
Things to learn:Only interface is enough which inherits to CrudRepository. The implementation will be provided by spring.To know the other inherited methods, please go through the CrudRepository API.
![Page 24: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/24.jpg)
JPA in Spring Boot
![Page 25: Introduction to spring boot](https://reader030.vdocuments.net/reader030/viewer/2022021415/5879919b1a28ab95318b5b85/html5/thumbnails/25.jpg)
Code
https://github.com/santoshkar/SpringBoot.git
The code can be downloaded from: