How to use Spring Factory Method to create Spring Bean

Spring Framework provides Spring Factory Method mechanics to create Beans from static(non-static) method of a Factory Class in XML config files. In the tutorial, JavaSampleApproach will introduce Spring Factory Method with sample codes.

Related Posts:
How to inject Collection in Spring
Inject Properties from Properties File using Spring Environment

[Continue reading…] “How to use Spring Factory Method to create Spring Bean”

@Resource Annotation in Spring

@Resource Annotation is used to indicate a reference to a resource, it is considered an alternative to @Autowired which is an Spring standard. Similar to Java EE 5, we can use @Resource Annotation with field injection or setter method.

This tutorial will cover those kinds of injection which will be used for matching by Name, Type or Qualifier.

[Continue reading…] “@Resource Annotation in Spring”

Spring Security – Config Security for Web MVC by Spring Boot

Security is an important of a Web Application, So The tutorial will guide you how to configure Security for a Web Application with Spring Boot.

Related Articles:
How to use Spring Security JDBC Authentication with PostgreSQL & Spring Boot
Spring Security – Customize Authentication Provider
Spring Security – Customize Login Handler
Spring Security Customize Logout Handler

[Continue reading…] “Spring Security – Config Security for Web MVC by Spring Boot”

Spring Profiles – @Profile Annotation and XML Configuration

In application development, sometimes we should make different configuration for each environment. Spring Profiles provides a way to separate application configuration into some parts and they are only available in one or more specific environments.

This tutorial introduces ways to use Spring Profiles by @Profile Annotation or XML Configuration.

[Continue reading…] “Spring Profiles – @Profile Annotation and XML Configuration”

Inject Properties using @Value Annotations vs Environment vs @ConfigurationProperties

@Value Annotations vs Environment vs @ConfigurationProperties.

Spring provides some ways to inject properties from properties file. We have learned how to use them in 3 articles:
@Value Annotation
Environment
@ConfigurationProperties

This tutorial helps you have a comparison view covering those solutions.

[Continue reading…] “Inject Properties using @Value Annotations vs Environment vs @ConfigurationProperties”

Inject Properties from Properties File using Spring Environment

We can load properties value from Properties file to Spring Environment just by using @PropertySource annotation. This tutorial shows you the simple way to get them from Environment object.

Related Articles:
Inject Properties from Properties File using @Value annotation
Inject Properties from Properties File using @ConfigurationProperties Annotation
How to use Spring Factory Method to create Spring Bean

[Continue reading…] “Inject Properties from Properties File using Spring Environment”

Inject Properties from Properties File using @ConfigurationProperties Annotation

This tutorial will show you the better way to handle properties using @ConfigurationProperties Annotation.

In previous article, we have learned about using @Value annotation to inject properties from properties file. This approach has disadvantage that if we wanna change any property, we have to update all files which referenced it.

[Continue reading…] “Inject Properties from Properties File using @ConfigurationProperties Annotation”

Inject Properties from Properties File using @Value Annotation

This tutorial shows you the way to inject Properties from Properties File using @Value Annotation with Java Configuration and @PropertySource.

You will also know how to use SourcesPlaceHolder and ConversionService for specific cases including: List/Arrays, special types (DateTime, Pattern), when a value that should be treated as null or a placeholder fails to resolve.

[Continue reading…] “Inject Properties from Properties File using @Value Annotation”

Difference between annotation-config and component-scan

annotation-config and component-scan are important basic concepts of Spring Core.
This tutorial helps you understand how to use them and difference between them.

[Continue reading…] “Difference between annotation-config and component-scan”

Spring IoC Container

At the Core of Spring Framework, Spring IoC (Inversion of Control) is implemented using the Dependency Injection design pattern. The Spring IoC Container creates, configures and connects the objects (which are called Beans), then manage their life cycle.

This tutorial introduce principle of Spring IoC and a simple example using Containers to you.

[Continue reading…] “Spring IoC Container”

Spring Bean Scope using Annotation – Singleton, Prototype, Request, Session, Global Session, Application

The tutorial shows you the way to implement Bean Scopes (Singleton, Prototype, Request and Session) using Annotation @Scope. Except Singleton and Prototype Scope, the others are only valid in the context of a web-aware Application.

Related Article: Spring Bean Scope – Singleton and Prototype

[Continue reading…] “Spring Bean Scope using Annotation – Singleton, Prototype, Request, Session, Global Session, Application”