feign調用返回object類型轉換成實體


    <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.8</version>
        </dependency> 
    /**
	 * @Description: 將數據轉換到相應的容器
	 * @return
	 * @throws
	 */
	public static <T> T convertValue(Object bean, Class<T> clazz){
		try{
			ObjectMapper mapper = new ObjectMapper();
			return mapper.convertValue(bean, clazz);
		}catch(Exception e){
			logger.error("錯誤的轉換:BeanUtil.convertValue() --->" + e.getMessage());
			return null;
		}
	}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM