Core Spring 5 Certification in Detail
Core Spring 5 Certification in Detail
Minimum price
Suggested price
Core Spring 5 Certification in Detail

This book is 90% complete

Last updated on 2019-01-15

About the Book

A walk-through of the study guide to Pivotal's Core Spring Certification for Spring Framework 5 with detailed answers and explanations. Please see the sample of the book for complete information about the topics that are going to be covered in the book and a detailed table of contents.

About the Author

Ivan Krizsan
Ivan Krizsan

I am a software developer since the age of 15.

During the last few years I have also become an author, since I very much enjoy writing as a way of learning.

In my spare time I enjoy motorcycle riding, carpentry, making music and exercise in different forms.

Finally I want to extend my gratitude to the people who read and comment on my articles. It is a privilege for me to be able to learn more and to improve my articles.

My blog is available at:

Table of Contents

Introduction 2

Organization 2

Table of Contents 3

Container, Dependency and IoC 10

What is dependency injection and what are the advantages? 10

What is a pattern? What is an anti-pattern? Is dependency injection a pattern? 11

What is a pattern? 11

What is an anti-pattern? 11

Is dependency injection a pattern? 11

What is an interface and what are the advantages of making use of them in Java? 12

Why are interfaces recommended for Spring beans? 12

What is meant by application-context? 13

What is the concept of a “container” and what is its lifecycle? 14

How are you going to create a new instance of an ApplicationContext? 16

Non-Web Applications 16

AnnotationConfigApplicationContext 16

Web Applications 17

Servlet 2 – ContextLoaderListener and web.xml 17

Servlet 2 – ContextLoaderListener, DispatcherServlet and web.xml 17

Servlet 3 – Web Application Initializers 18

Servlet 3 – XmlWebApplicationContext 19

Servlet 3 – AnnotationConfigWebApplicationContext 20

Can you describe the lifecycle of a Spring Bean in an ApplicationContext? 21

How are you going to create an ApplicationContext in an integration test? 23

JUnit 4 Example 23

JUnit 5 Example 23

Web Application Context 24

What is the preferred way to close an application context? Does Spring Boot do this for you? 26

Standalone Application 26

Web Application 26

Spring Boot Closing Application Context 26

Dependency Injection, Component Scanning, Meta-Annotations and Bean Scopes 27

Describe dependency injection using Java configuration 27

Describe dependency injection using annotations (@Component, @Autowired) 27

Describe component scanning, Stereotypes and Meta-Annotations 28

Component scanning 28

Stereotype Annotations 29

Meta-Annotations 29

Describe scopes for Spring beans? What is the default scope? 30

Are beans lazily or eagerly instantiated by default? How do you alter this behavior? 32

What is a property source? How would you use @PropertySource? 33

What is a BeanFactoryPostProcessor and what is it used for? When is it invoked? 34

When is a bean factory post processor invoked? 34

Why would you define a static @Bean method? 34

What is a ProperySourcesPlaceholderConfigurer used for? 35

What is a BeanPostProcessor and how is it different to a BeanFactoryPostProcessor? What do they do? When are they called? 36

BeanPostProcessor 36

BeanFactoryPostProcessor 36

What is an initialization method and how is it declared on a Spring bean? 37

What is a destroy method, how is it declared and when is it called? 39

Consider how you enable JSR-250 annotations like @PostConstruct and @PreDestroy? When/how will they get called? 41

How else can you define an initialization or destruction method for a Spring bean? 41

What does component-scanning do? 41

What is the behavior of the annotation @Autowired with regards to field injection, constructor injection and method injection? 42

@Autowired and Field Injection 43

@Autowired and Constructor Injection 43

@Autowired and Method Injection 44

What do you have to do, if you would like to inject something into a private field? How does this impact testing? 46

Using @Autowired or @Value 46

Using Constructor Parameters 46

Testing and Private Fields 46

How does the @Qualifier annotation complement the use of @Autowired? 48

@Qualifier at Injection Points 48

@Qualifier at Bean Definitions 48

@Qualifier at Annotation Definitions 48

What is a proxy object and what are the two different types of proxies Spring can create? 49

Types of Spring Proxy Objects 49

What are the limitations of these proxies (per type)? 49

Limitations of JDK Dynamic Proxies 50

Limitations of CGLIB Proxies 50

What is the power of a proxy object and where are the disadvantages? 50

What are the advantages of Java Config? What are the limitations? 52

What does the @Bean annotation do? 53

What is the default bean id if you only use @Bean? How can you override this? 54

Why are you not allowed to annotate a final class with @Configuration? 55

How do @Configuration annotated classes support singleton beans? 55

Why can’t @Bean methods be final either? 55

How do you configure profiles? What are possible use cases where they might be useful? 57

Configuring Profiles for Beans 57

Activating Profile(s) 58

Can you use @Bean together with @Profile? 59

Can you use @Component together with @Profile? 59

How many profiles can you have? 59

How do you inject scalar/literal values into Spring beans? 60

What is @Value used for? 61

What is Spring Expression Language (SpEL for short)? 62

Complete Standalone Expression Templating Examples 63

Compiled SpEL Expressions 64

What is the Environment abstraction in Spring? 65

Environment Class Hierarchy 69

Relation Between Application Context and Environment 69

Where can properties in the environment come from – there are many sources for properties – check the documentation if not sure. Spring Boot adds even more. 71

What can you reference using SpEL? 72

What is the difference between $ and # in @Value expressions? 73

Aspect Oriented Programming 74

What is the concept of AOP? Which problem does it solve? What is a cross cutting concern? 74

What is the concept of AOP? 74

What is a cross cutting concern? 76

Name three typical cross cutting concerns. 76

Which problems does AOP solve? 77

What two problems arise if you don't solve a cross cutting concern via AOP? 77

What is a pointcut, a join point, an advice, an aspect, weaving? 79

Join Point 79

Pointcut 80

Advice 82

Aspect 82

Weaving 83

How does Spring solve (implement) a cross cutting concern? 84

JDK Dynamic Proxies 84

CGLIB Proxies 85

Which are the limitations of the two proxy-types? 86

JDK Dynamic Proxies 86

CGLIB Proxies 86

What visibility must Spring bean methods have to be proxied using Spring AOP? 87

How many advice types does Spring support. Can you name each one? 88

What are they used for? 88

Before Advice 88

After Returning Advice 89

After Throwing Advice 89

After (Finally) Advice 90

Around Advice 91

Which two advices can you use if you would like to try and catch exceptions? 91

What do you have to do to enable the detection of the @Aspect annotation? 93

What does @EnableAspectJAutoProxy do? 93

If shown pointcut expressions, would you understand them? 94

Basic Structure of Pointcut Expressions 94

Combining Pointcut Expressions 94

Pointcut Designators 95

Pointcut designator: execution 95

Pointcut designator: within 96

Pointcut designator: this 96

Pointcut designator: target 96

Pointcut designator: args 97

Pointcut designator: @target 97

Pointcut designator: @args 97

Pointcut designator: @within 98

Pointcut designator: @annotation 98

Pointcut designator: bean 98

For example, in the course we matched getter methods on Spring Beans, what would be the correct pointcut expression to match both getter and setter methods? 99

What is the JoinPoint argument used for? 100

What is a ProceedingJoinPoint? When is it used? 102

Data Management: JDBC, Transactions, JPA, Spring Data 103

What is the difference between checked and unchecked exceptions? 103

Why does Spring prefer unchecked exceptions? 103

What is the data access exception hierarchy? 103

How do you configure a DataSource in Spring? Which bean is very useful for development/test databases? 103

What is the Template design pattern and what is the JDBC template? 103

What is a callback? What are the three JdbcTemplate callback interfaces that can be used with queries? What is each used for? (You would not have to remember the interface names in the exam, but you should know what they do if you see them in a code sample) 103

Can you execute a plain SQL statement with the JDBC template? 104

When does the JDBC template acquire (and release) a connection - for every method called or once per template? Why? 104

How does the JdbcTemplate support generic queries? How does it return objects and lists/maps of objects? 104

What is a transaction? What is the difference between a local and a global transaction? 104

Is a transaction a cross cutting concern? How is it implemented by Spring? 104

How are you going to define a transaction in Spring? 104

What does @Transactional do? What is the PlatformTransactionManager ? 104

Is the JDBC template able to participate in an existing transaction? 104

What is a transaction isolation level? How many do we have and how are they ordered? 105

What is @EnableTransactionManagement for? 105

What does transaction propagation mean? 105

What happens if one @Transactional annotated method is calling another @Transactional annotated method on the same object instance? 105

Where can the @Transactional annotation be used? What is a typical usage if you put it at class level? 105

What does declarative transaction management mean? 105

What is the default rollback policy? How can you override it? 105

What is the default rollback policy in a JUnit test, when you use the @RunWith(SpringJUnit4ClassRunner.class) in JUnit 4 or @ExtendWith(SpringExtension.class) in JUnit 5, and annotate your @Test annotated method with @Transactional ? 105

Why is the term "unit of work" so important and why does JDBC AutoCommit violate this pattern? 105

What does JPA stand for - what about ORM? 106

What is the idea behind an ORM? What are benefits/disadvantages or ORM? 106

What is a PersistenceContext and what is an EntityManager . What is the relationship between both? 106

Why do you need the @Entity annotation. Where can it be placed? 106

What do you need to do in Spring if you would like to work with JPA? 106

Are you able to participate in a given transaction in Spring while working with JPA? 106

Which PlatformTransactionManager (s) can you use with JPA? 106

What does @PersistenceContext do? 106

What do you have to configure to use JPA with Spring? How does Spring Boot make this easier? 106

What is an "instant repository"? (hint: recall Spring Data) 106

How do you define an “instant” repository? Why is it an interface not a class? 107

What is the naming convention for finder methods? 107

How are Spring Data repositories implemented by Spring at runtime? 107

What is @Query used for? 107

Spring Boot 107

What is Spring Boot? 107

What are the advantages of using Spring Boot? 107

Why is it “opinionated”? 107

How does it work? How does it know what to configure? 107

What things affect what Spring Boot sets up? 107

How are properties defined? Where is Spring Boot’s default property source? 107

Would you recognize common Spring Boot annotations and configuration properties if you saw them in the exam? 108

What is the difference between an embedded container and a WAR? 108

What embedded containers does Spring Boot support? 108

What does @EnableAutoConfiguration do? 108

What about @SpringBootApplication? 108

Does Spring Boot do component scanning? Where does it look by default? 108

What is a Spring Boot starter POM? Why is it useful? 108

Spring Boot supports both Java properties and YML files. Would you recognize and understand them if you saw them? 108

Can you control logging with Spring Boot? How? 108

Spring MVC and the Web Layer 109

MVC is an abbreviation for a design pattern. What does it stand for and what is the idea behind it? 109

Do you need spring-mvc.jar in your classpath or is it part of spring-core? 109

What is the DispatcherServlet and what is it used for? 109

Is the DispatcherServlet instantiated via an application context? 109

What is a web application context? What extra scopes does it offer? 109

What is the @Controller annotation used for? 109

How is an incoming request mapped to a controller and mapped to a method? 109

What is the difference between @RequestMapping and @GetMapping? 109

What is @RequestParam used for? 110

What are the differences between @RequestParam and @PathVariable? 110

What are some of the parameter types for a controller method? 110

What other annotations might you use on a controller method parameter? (You can ignore form-handling annotations for the exam) 110

What are some of the valid return types of a controller method? 110

What is a View and what's the idea behind supporting different types of View ? 110

How is the right View chosen when it comes to the rendering phase? 110

What is the Model ? 110

Why do you have access to the model in your View ? Where does it come from? 110

What is the purpose of the session scope? 111

What is the default scope in the web context? 111

Why are controllers testable artifacts? 111

What does a ViewResolver do? 111

Security 112

What are authentication and authorization? Which must come first? 112

Authentication 112

Authorization 112

Which must come first? 113

Is security a cross cutting concern? How is it implemented internally? 114

Security – A Cross-Cutting Concern? 114

How is security implemented internally in Spring Security? 114

Spring Security Web Infrastructure 114

Spring Security Core Components 117

What is the delegating filter proxy? 120

What is the security filter chain? 120

Request Matcher 121

Filters 121

What is a security context? 123

Why do you need the intercept-url? 125

In which order do you have to write multiple intercept-url's? 126

What does the ** pattern in an antMatcher or mvcMatcher do? 126

Why is an mvcMatcher more secure than an antMatcher? 126

Does Spring Security support password hashing? What is salting? 127

Password Hashing 127

Salting 127

Why do you need method security? What type of object is typically secured at the method level (think of its purpose not its Java type). 127

Why do you need method security? 127

What type of object is typically secured at method level? 128

What do @PreAuthorized and @RolesAllowed do? What is the difference between them? 128

@PreAuthorize 128

@RolesAllowed 128

What does Spring’s @Secured do? 128

How are these annotations implemented? 129

In which security annotation are you allowed to use SpEL? 129

Is it enough to hide sections of my output (e.g. JSP-Page or Mustache template)? 129

Spring security offers a security tag library for JSP, would you recognize it if you saw it in an example? 130

The authorize Tag 130

The authentication Tag 130

The accesscontrollist Tag 130

The csrfInput Tag 130

The csrfMetaTags Tag 131

REST 132

What does REST stand for? 132

What is a resource? 132

What does CRUD mean? 132

Is REST secure? What can you do to secure it? 132

What are safe REST operations? 132

What are idempotent operations? Why is idempotency important? 132

Is REST scalable and/or interoperable? 132

Which HTTP methods does REST use? 133

What is an HttpMessageConverter? 133

Is REST normally stateless? 133

What does @RequestMapping do? 133

Is @Controller a stereotype? Is @RestController a stereotype? 133

What is a stereotype annotation? What does that mean? 133

What is the difference between @Controller and @RestController? 133

When do you need @ResponseBody? 133

What does @PathVariable do? 134

What are the HTTP status return codes for a successful GET, POST, PUT or DELETE operation? 134

When do you need @ResponseStatus? 134

Where do you need @ResponseBody? What about @RequestBody? Try not to get these muddled up! 134

If you saw example Controller code, would you understand what it is doing? Could you tell if it was annotated correctly? 134

Do you need Spring MVC in your classpath? 134

What Spring Boot starter would you use for a Spring REST application? 134

What are the advantages of the RestTemplate? 134

If you saw an example using RestTemplate would you understand what it is doing? 134

Testing 135

Do you use Spring in a unit test? 135

What type of tests typically use Spring? 135

How can you create a shared application context in a JUnit integration test? 135

When and where do you use @Transactional in testing? 135

How are mock frameworks such as Mockito or EasyMock used? 135

How is @ContextConfiguration used? 135

How does Spring Boot simplify writing tests? 135

What does @SpringBootTest do? How does it interact with @SpringBootApplication and @SpringBootConfiguration? 135

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub