1

I am autowiring a property(its a component) in an abstract class, This is not working , always coming a null; The same property has been autowired in other abstract class which is working absolutely fine. can some one please tell me , what would be the problem?

public abstract class BaseRegistry {

    @Autowired
    PropertyConfig propertyConfig; 
}

@Repository
public class OptionsRegistry extends BaseRegistry{
}

@Component
public class PropertyConfig {
}
user2334926
  • 321
  • 2
  • 7
  • 16
  • Possible duplicate of [Spring can you autowire inside an abstract class?](http://stackoverflow.com/questions/19965829/spring-can-you-autowire-inside-an-abstract-class) – M. Rizzo Feb 16 '17 at 21:33
  • Is this happening in a JUnit test? Else show your application configuration, maybe you are not scanning all packages if you use `@ComponentScan` with `basePackage`. – aliopi Feb 17 '17 at 06:48
  • Nope, not in junit. well, i checked the component base scan, it looks good. the abstract class is in package, com.test.base.registry and the component base scan is com.test.base. The same autowiring is working for another abstract class. not sure whats the problem here. – user2334926 Feb 17 '17 at 14:40
  • Its a Spring boot application, and here is my App.java – user2334926 Feb 17 '17 at 15:25
  • **@SpringBootApplication(scanBasePackages = { "com.test.base" })** public class App { private static final Logger LOGGER = LoggerFactory.getLogger(App.class); private static ConfigurableApplicationContext ctx; public static ConfigurableApplicationContext getCtx() { return ctx; } public static void main(String[] args) { LOGGER.info("Starting the app..."); ctx = SpringApplication.run(App.class, args); } } – user2334926 Feb 17 '17 at 15:26

0 Answers0