How can I @Autowire a spring bean that was created from an external jar?

前端 未结 4 1650
情话喂你
情话喂你 2020-12-02 18:21

I have a module/jar that I\'ve created and am using as a util library. I created a service in there like so:

@Service
public class          


        
4条回答
  •  鱼传尺愫
    2020-12-02 18:41

    You have to scan at least the package containing the class you want to inject. For example, with Spring 4 annotation:

    @Configuration
    @ComponentScan("com.package.where.my.class.is")
    class Config {
    ...
    }
    

    It is the same principle for XML configuration.

提交回复
热议问题