I am trying to use Spring Autowired and Configs without using springboot. I have the below dependencies and the class look like below (I got a service, component and config class). But I get SomeService as null always. What am I missing?
Config
@Configuration
@EnableAutoConfiguration
@ComponentScan("com.somepackage")
public class AppConfig {
}
Component
@Component
public class TestClass extends Step {
@Autowired
private SomeService someservice;
public void testConnectivity() {
someservice.insertTransaction();
}
}
Service
@Service
public class SomeService {
}
MainClass
public class Application {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(Application .class);
application.setWebApplicationType(WebApplicationType.NONE);
application.run(args);
}
}
Dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.4.5</version>
</dependency>