I would like to autowire an object from an external JAR that I use it in my application:
@Autowired
PythonInterpreter interp;
I get this Exception :
Field interp in com.package.services.ServicesImpl required a bean of type 'org.python.util.PythonInterpreter' that could not be found.
Action:
Consider defining a bean of type 'org.python.util.PythonInterpreter' in your configuration.
I know that @ComponentScan
will only work if the class is annotated with @Component
.
The point is: you have to tell Spring how to create an instance of that class.
See their example in their documentation:
@Configuration
public class AppConfig {
@Bean
public MyService myService() {
return new MyServiceImpl();
}
}
So, as the first comment correctly tells you: you need to define a method that somehow creates that object. Then you annotate that method as @Bean, and make sure that Spring finds it as @Configuration.