Andrew Golovko
@andrewgolovko
Blog of a self-taught programmer writing about the experience, tips and other stuff
153 posts
Spring
Spring Container, Dependency, IoC

M01 Q32 Where can properties in the environment come from?

Property Sources in Spring Application vary based on the type of applications that is being executed:

M01 Q31 What is the Environment abstraction?

Environment Abstraction is part of the Spring Container that models two key aspects of the application environment:

M01 Q30 What is SpEL?

Spring Expression Language (SpEL) is an expression language that allows you to query and manipulate objects graphs during the runtime. SpEL is used in different products across the Spring portfolio.

M01 Q29 What is @Value used for?

@Value is used for:

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

To inject scalar/literal values into Spring Beans, you need to use @Value annotation. @Value annotation has only one field value.

M01 Q27 How many profiles can you have?

Spring Framework does not specify any explicit limit on the number of profiles. However, since some of the classes in Framework are using an array to iterate over profiles.

M01 Q26 Can you use @Component together with @Profile?

Yes, @Profile annotation can be used together with @Component on top of the class representing spring bean.

M01 Q25 Can you use @Bean together with @Profile?

Yes, @Bean annotation can be used together with @Profile inside class annotated with @Configuration annotation on top of the method that returns an instance of the bean.

M01 Q24 What is @Profile annotation?

Spring Profiles are configured by:

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

A class annotated with @Configuration cannot be final because Spring will use CGLIB to create a proxy for @Configuration class. CGLIB creates subclass for each class that is supposed to be proxied, however since the final class cannot have subclass CGLIB will fail. This is also a reason why methods cannot be final, Spring needs to override methods from parent class for the proxy to work correctly, however, final method cannot be overridden, having such a method will make CGLIB fail.