Spring Tutorial

Spring Application Start Throw BeanDefinitionStoreException

When your Spring application startup, you may sometimes encounter such exceptions. org.springframework.beans.factory.BeanDefinitionStoreException. And the error message maybe like below.  Failed to read candidate component class: file nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file – probably due to a new Java class file version that isn’t supported yet: nested exception is java.lang.IllegalArgumentException …

Spring Application Start Throw BeanDefinitionStoreException Read More »

Spring Bean Dependency Injection Methods Comparison – Setter Vs Constructor

In Spring Framework, there are two methods that you can use to achieve spring bean Dependency Injection ( DI ). Use spring bean setter method. Use spring bean’s constructor. Bean Injection Use Setter Method This is the most commonly used bean dependency injection method. You just need to do following. Create an instance variable with …

Spring Bean Dependency Injection Methods Comparison – Setter Vs Constructor Read More »

How To Inject Value To Spring Bean Properties

If you want to set your Spring bean’s property value in bean configuration file, you can use below methods. Use property tag under bean tag. <bean id=”beanPropsInjection” name=”beanPropsInjection” class=”com.dev2qa.example.spring.BeanPropertiesInjection”> <property name=”loginUserName” value=”dev2qa.com”></property> <property name=”loginPassword” value=”dev2qa.com”></property> </bean> Use bean tag attribute prefixed with p schema. But before do below configuration, you should add namespace xmlns:p=”http://www.springframework.org/schema/p” in the …

How To Inject Value To Spring Bean Properties Read More »

Spring Component Scan Instruction

After you configure <context:component-scan base-package=”com.dev2qa.examples”> in Spring bean configuration xml file, Spring container can automatically scan the java files under base-pack and it’s sub packages. If it has scanned the classes with annotations like @Component, @Service, @Repository or @Controller, the container will register these classes as managed bean.