Spring Framework 4 Cheat Sheet
Modules
Core
spring-core
spring-beans
spring-context
spring-expression
AOP and Instrumentation
spring-aop
spring-aspects
spring-instrument
spring-instrument-tomcat
Messaging
spring-messaging
Data Access/Integration
spring-jdbc
spring-tx
spring-orm
spring-oxm
spring-jms
Web
spring-web
spring-webmvc
spring-webmvc-portlet
spring-websocket
Test
spring-test
http://docs.spring.io/spring-framework/docs/current/spring-
framework-reference/html/overview.html#overview-modules
Spring MVC - Controller
@ControllerAnnotation to indicate that the class is a controller
class.
@RestControllerA convenience annotation that is itself annotated
with @Controller and @ResponseBody. Used
in controllers that will behave as RESTful
resources.
@RequestMappingAnnotation to be used on methods in
@RestController classes. You can provide anURI to be served as RESTful service.
@ModelAttributeAnnotation used to bind values present in views.
Configuration
@Configuration
Annotation used to provide configurations.
Configuration (cont)
@BeanAnnotation that acts like a provider where you can define how
the bean is instantiated when a injection of that type is
requested. Instances of @Bean annotated methods will act as
singletons.
Properties Evaluation Sequence
Command-line arguments
java -Dproject.name=Test -jarapp.jar
System properties
System.getProperties()
Environment Variable
export PROJECT_NAME=TestExternal properties/yml
file
project.name=Test
Internal properties/yml file
project.name=Test
The default properties/yml files are application.properties and
application.yml and they are located in /src/resources.
Spring Boot Initializer
http://start.spring.io
Web service that allows the user to specify the
project metadata and dependencies as well as
download the initial structure.
Spring CLI
A CLI tool that interacts with http://start.spring.io
service to scaffold a new project.
Spring Tool Suit
Eclipse-based IDE that also interacts with
http://start.spring.io to scaffold a new project.
Intellij IDEA
Intellij also provides a way of creating a new project
via http://start.spring.io.
Spring Boot - Auto Configuration
@ConditionalOnClass@ConditionalOnClass(Tomcat.class)
Only available if
the Tomcat
class is found in
the classpath.
@ConditionalOnProperty@ConditionalOnProperty(name =
"tomcat.version",
matchIfMissing =
true)
Only available if
the property
tomcat.versi
on is set to true.
Auto configuration is just the combination of @Configuration and
@Conditional* annotations in order to correctly register beans.By danielfc
Learn to solve cryptic crosswords!