-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Description
Michael Isvy opened SPR-6837 and commented
I'm using the following configuration:
<bean class="factory.ClientServiceSingleton" id="clientServiceSingleton" factory-method="getInstance"/>
public class ClientServiceSingleton {
private static ClientServiceSingleton instance = new ClientServiceSingleton();
private ClientServiceSingleton() {}
public ClientServiceSingleton getInstance() {
return instance;
}
}
As you might have noticed, I have omitted declaring the getInstance method as static.
In that case, the error message is as follows:
Error creating bean with name 'clientServiceSingleton' defined in class path resource [factory/method/factorymethod-config.xml]:
No matching factory method found: factory method 'getInstance'
Also, STS is not showing an explicit message either.
I believe the error message could show something such as:
No matching factory method found: factory method 'getInstance'. Check that the method exists and that it is static.
note: in case the return type is incorrect, it crashes far after, when injecting the dependency. So at this stage, the error message should not mention that the return type might be wrong.
Referenced from: commits 18bd4a8
Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement