on 06-23-2015 10:35 AM
Getting this error- Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'flexibleSearchService' of bean class [com.tisl.mpl.bin.daos.BinDao]: Bean property 'flexibleSearchService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
It seems that your class misses either a correct setter for that type or a correct annotation on the type; depending on the context.
But basically putting a @Autowired over the service declaration should solve the problem.
public class MyClass {
@Autowired
private HybrisService hybrisService;
public void myMethod() {
// some stuff here
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I reckon you are doing property injection. Hence it requires a public setter method in your java class file whose bean in which flexiblesearchservice property was used in spring.xml.
If you want to don't want to do property injection, simply remove the property in spring.xml and use @Resource or @Autowired annotations above your property declaration in your java class file, which have their own strategy of picking the right bean to be injected from the application context.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you add a setter method for it? I would assume from the exception that you have defined it as a bean property but are missing a public set method. Antoher possibility is that your DAO extends something else that has this dependecy but you have not configured this in your xml . You could add "parent" attribute to your bean definition and then you will get those dependencies.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It still did not work. Is it occuring because its a new extension? Do I need to add some dependencies? Can you please suggest?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you inject the flexibleSearchService with annotations, or via xml ? In the second case, the annotation won't help if you have a definition like that:
<bean id="myClass" class="be.custom.MyClass">
<property name="flexibleSearchService" ref="flexibleSearchService" />
</bean>
In that case, you need then to update your class with a setter:
public class MyClass {
private FlexibleSearchService flexibleSearchService ;
public void myMethod() {
// some stuff here
}
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService) {
this.flexibleSearchService = flexibleSearchService;
}
}
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.