Spring项目—多模块依赖问题

创建多module的项目时,我们通常会在不同的模块中写业务逻辑。当一个模块依赖于另外一个模块中的类的时候,可能会报下面的错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field token in com.aolingo.tstevo.server.gateway.TokenLegalInterceptor required a bean of type 'com.aolingo.tstevo.token.IToken' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.aolingo.tstevo.token.IToken' in your configuration.

这是因为不同的模块之间的spring类引用时,需要在application的类中指定需要扫描的包名,这样spring就会将其他模块中的spring bean也管理起来了。

@ComponentScan(basePackages = {"com.aolingo.tstevo.token","com.aolingo.tstevo.common","com.aolingo.tstevo.server"})