JPA javax.persistence.EntityNotFoundException: Unable to find

JPA报错如下:

javax.persistence.EntityNotFoundException: Unable to find com.wemall.foundation.domain.SpareGoodsFloor with id 2
	at [hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
	at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:242) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
	at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:159) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
	at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:266) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
	at com.wemall.foundation.domain.SpareGoodsFloor_$$_jvst28a_26.getAddTime(SpareGoodsFloor_$$_jvst28a_26.java) ~[classes/:na]
com.alibaba.fastjson.serializer.ASMSerializer_52_SpareGoods.write(Unknown Source) ~[na:na]
	at 
	

图片:
在这里插入图片描述
查看实体类:
在这里插入图片描述
如果过出现这个Data类型的参数,那么有可能是,你使用的


			com.alibaba
			fastjson
			1.2.51

然后请修改:

@SpringBootApplication
@EnableDiscoveryClient
public class CartApplication {

	@Bean//使用@Bean注入fastJsonHttpMessageConvert
	public HttpMessageConverters fastJsonHttpMessageConverters(){
		//1.需要定义一个Convert转换消息的对象
		FastJsonHttpMessageConverter fastConverter=new FastJsonHttpMessageConverter();
		//2.添加fastjson的配置信息,比如是否要格式化返回的json数据
		FastJsonConfig fastJsonConfig=new FastJsonConfig();
		fastJsonConfig.setSerializerFeatures( SerializerFeature.PrettyFormat);
		//3.在convert中添加配置信息
		fastConverter.setFastJsonConfig(fastJsonConfig);

		HttpMessageConverter converter=fastConverter;
		return new HttpMessageConverters (converter);
	}
	public static void main(String[] args) {
		SpringApplication.run(CartApplication.class, args);
	}
}

你可能感兴趣的:(Spring)