Spring Boot is a framework for building stand-alone, production-grade Spring based Applications that can be "just run". It takes an opinionated view of the Spring platform and third-party libraries so developers can get started with minimum fuss. Some key features include an embedded HTTP server and automatic configuration support. Spring Boot applications can be started using Java -jar or executed using Gradle/Maven and can be packaged as an executable jar or war file for deployment. The document also discusses using Spring Boot with databases, profiles, Spring Data, GORM, views and some miscellaneous topics.
12. Exercise
- Use actuator starter POM in gradle application just created
- Use security starter POM in gradle application just
created
- Changing the default embedded servlet container and the
port
18. 1. A /config subdir of the current directory.
2. The current directory
3. A classpath /config package
4. The classpath root
Don’t forget commandLine. It’s the Master here.
20. logging.file logging.path Example Description
(none) (none) Console only logging.
Specific file (none) my.log Writes to the specified log
file. Names can be an exact
location or relative to the
current directory.
(none) Specific directory /var/log Writes spring.log to the
specified directory. Names
can be an exact location or
relative to the current
directory.
22. ID Description Sensitive
autoconfig Displays an auto-configuration report showing all auto- configuration
candidates and the reason why they ‘were’ or ‘were not’ applied.
true
beans Displays a complete list of all the Spring beans in your application. true
configprops Displays a collated list of all @ConfigurationProperties. true
dump Performs a thread dump. true
env Exposes properties from Spring’s ConfigurableEnvironment. true
health Shows application health information (a simple ‘status’ when accessed over
an unauthenticated connection or full message details when authenticated).
false
info Displays arbitrary application info. false
metrics Shows ‘metrics’ information for the current application. true
mappings Displays a collated list of all @RequestMapping paths. true
shutdown Allows the application to be gracefully shutdown (not enabled by default). true
trace Displays trace information (by default the last few HTTP requests). true
23. The prefix #endpoints + . + name” is used to uniquely identify
the endpoint that is being configured.
E.g.
endpoints.beans.id=springbeans
endpoints.beans.sensitive=false
endpoints.shutdown.enabled=true
24. :
•
•
•
compile 'mysql:mysql-connector-java:5.1.6'
compile 'org.springframework.boot:spring-boot-starter-jdbc'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
spring.datasource.url= jdbc:mysql://localhost/springboot
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create-drop
import javax.persistence.Entity
import javax.persistence.Id
class City{@Id String id, String name , String state
protected City() {}
public City(String name, String state) {
this.name = name
this.state = state
}}
28. •
28
@RequestMapping("/show/{id}")
public ModelAndView show(@PathVariable Long id) {
Person person = Person.read(id)
if (person) {
new ModelAndView("/person/show", [personInstance: Person.get(id)])
} else {
log.info "No entity fount for id : " + id
new ModelAndView("redirect:/person/list")
}
}
30. - Messaging (JMS)
- NOSQL / SQL database support
- Mailing
- Testing
- Monitoring and Management using JMX
- Hot Swapping - reloading content on run
time
32. com
+- example
+- myproject
+- Application.java(Main class)
|
+- domain
| +- Customer.java
| +- CustomerRepository.java
|
+- service
| +- CustomerService.java
|
+- web
+- CustomerController.java
Fig.: Typical structure to be followed
33. Miscellaneous
- Enabling Disabling the Banner
- Changing the Banner
(http://www.kammerl.de/ascii/AsciiSignature.php)
- Adding event Listeners
- Logging startup info
35. ● Idea behind Spring Boot.
● It’s key Features
● Easy start with Spring Boot using CLI.
● .
● Using Spring boot with build tools - gradle, maven.
● Packaging executable jar files / war files.
● Environment AKA Profile
● Persisting data using Spring Data
● Next level persistence using GORM
● Creating Views a Glimpse
● Some Misc.