package com.mkyong.output; IOutputGenerator.java
public interface IOutputGenerator
{
    public void generateOutput();
}
package com.mkyong.output; OutputHelper.java
@Component
public class OutputHelper {
    @Autowired
    IOutputGenerator outputGenerator;
    public void generateOutput() {
        outputGenerator.generateOutput();
    }
    /*//DI via setter method
    public void setOutputGenerator(IOutputGenerator outputGenerator) {
        this.outputGenerator = outputGenerator;
    }*/
}
package com.mkyong.output.impl;
CsvOutputGenerator.java
@Component
public class CsvOutputGenerator implements IOutputGenerator {
    public void generateOutput() {
        System.out.println("This is Csv Output Generator");
    }
}
SpringBeans.xml
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    <context:component-scan base-package="com.mkyong" />
</beans>
i am getting this exception Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'OutputHelper' is defined
even though i have marked OutputHelper as component.
 
     
     
     
    