Autowired injects the model object and returns an error after setting the object properties in the method.

@ Controller
@ RequestMapping ("/ andy")
public class helloContoller {

@Autowired
private PayService payService;
@Autowired
private Resource resource;
@Autowired
private Person person;


@RequestMapping ("/hello2")
@ResponseBody
public Person hello2(){
    person.setAge("132");
    person.setName("andy");
    return person;
}

}

return the report:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.example.controller.Resource$$EnhancerBySpringCGLIB$$397134d0 ["$$beanFactory"]-> org.springframework.beans.factory.support.DefaultListableBeanFactory ["beanExpressionResolver"])

Mar.02,2021

public class MyMapper extends ObjectMapper{ 
    public CustomMapper() {
        this.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        //  SerializationFeature.FAIL_ON_EMPTY_BEANS  false
        this.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    }
}
springmvc
<mvc:annotation-driven>
    <mvc:message-converters>
        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="supportedMediaTypes">
                <list>
                    <value>application/json; charset=UTF-8</value>
                    <value>application/x-www-form-urlencoded; charset=UTF-8</value>
                </list>
            </property>
            <property name="objectMapper">
                <bean class="MyMapper">
                </bean>
            </property>
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4ba52-44e2b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4ba52-44e2b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?