Classpath problem
In my application there are three seperate projects for task specifics:
- One Java project for service layer and dao layer (using Spring DI) -
business.jar
- One Java project for WS clients -
WSClient.jar
- Web project using Spring MVC -
MyApp.war
Now my problem is how to bind all projects together because the web app has to get dependencies from the service and DAO from business.jar
and services have to get dependencies from WSClient.jar
in terms of calling web services. I have to use classpath scan utility of Spring to autowire service dao and controller components from all these three projects.
But getting error because service layer is not in classpath:
factory.NoSuchBeanDefinitionException: No matching bean of type
[com.amex.merchant.site.pop.service.POPRenderService] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for this
dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true),
@org.springframework.beans.factory.annotation.Qualifier(value=pOPRenderService)}
Please suggest how to procee开发者_如何学Cd further
The POJO service layer should not have any dependency on web service clients. There shouldn't be a dependency on web service clients with POJO services, either. The POJO services need to be wrapped with "contract first" web services. Sounds like you're doing something wrong to me.
With that said, you need to create JARs from those projects and add them as dependencies to the other projects that need them. OR you can create a dependency in your IDE between projects and compile them all at once. That's not a Spring thing; it depends on your IDE.
As for your immediate problem, make sure that you have a Spring config somewhere with the <context:component-scan>
XML in it. It looks like Spring can't find your pOPRenderService
bean. If that's a dependency, it could be a CLASSPATH issue. Neither Spring nor the class loader can find the JAR with that .class file in it to resolve the dependency.
精彩评论