-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classes with abstract @Lookup methods not registered in case of classpath scanning [SPR-14550] #19118
Comments
Juergen Hoeller commented As far as my tests go, such scenarios work fine: We generally support classes with abstract Could you please submit a minimal use case that reproduces your specific scenario? |
Manfred Quasten commented Maven-Poject with JUnitTest |
Manfred Quasten commented I've attached a maven project with a JunitTest and a simple Senario. You are right spring will support abstract method scenarios. It will work, when the ServiceBean (ArtistService in my example project) is defined in XML ( application.xml in the example). The Test runs successfull. When you remove the ArtistService in application.xml and only the |
Juergen Hoeller commented This is actually a limitation in our classpath scanning algorithm: We generally do not register any non-concrete classes there. Explicit bean definitions, whether XML-based or through |
Juergen Hoeller commented Since we're not going to introduce a general mechanism for abstract types in our component scanner, I've added a specific check for abstract classes with |
Manfred Quasten commented Works in 4.3.6. Thanks and Regards |
Due to changes in gh-19118, classes that contain @Lookup methods are no longer required to be concrete classes for use with component scanning; however, the reference documentation still states that such classes must not be abstract. This commit therefore removes the outdated reference documentation and updates the corresponding Javadoc. See gh-19118 Closes gh-34367
Due to changes in gh-19118, classes that contain @Lookup methods are no longer required to be concrete classes for use with component scanning; however, the reference documentation still states that such classes must not be abstract. This commit therefore removes the outdated reference documentation and updates the corresponding Javadoc. See gh-19118 Closes gh-34367 (cherry picked from commit 819a7c8)
Manfred Quasten opened SPR-14550 and commented
@Service
("exchangeRateService")class ExchangeRateServiceImpl implements ExchangeRateService {
...
@Lookup
ExchangeRateCalculatorBuilder newBuilder() {
return null;
}
}
the newBuilder Method is used inside an other public method and it works fine.
But when I will make the service class and the method newBuilder abstract then an exception is thrown:
No qualifying bean of type [de.mq.portfolio.exchangerate.support.ExchangeRateService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Ok, I can understand, that the spring container will not instantiate abstract classes but when only methods for methodInjection are abstract the bean can be instantiated. It is enhanced by cglib or what ever and it works as I've tried without abtract. For the (cglib) proxy there is no difference if an abstract or an other method will be overwritten. It is not very esthetic to write the dummy method returning null or what ever and it is not nesseary. In case of an abstract class that has only abstract methods for method injection the container can instantite the proxy.
Affects: 4.2.5
Attachments:
Issue Links:
The text was updated successfully, but these errors were encountered: