Autowired on SpringBoot

1

Good morning everyone.

I run into the following problem in a Spring boot project. When I have an @ServiceController I can call all beans @Component and @Autowired that I have. Now if I want to do it from the main method of the @SpringBootApplication class I have to define the applicationContext.xml file and declare that I'm going to use @Autowired <context:component-scan base-package="com.miejemplo.miejemplodev"/>

then instantiate the applicationContext ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/applicationContext.xml");

to be able to use my beans.

Does anyone know if it can be used just like in an @ServiceController without defining the applicationContext.xml and without instantiating an applicationContext?

In my case I tried it but the beans remain in me.

Thank you very much already.

    
asked by user3424397 25.09.2017 в 00:34
source

0 answers