【发布时间】:2019-01-11 15:23:05
【问题描述】:
我有一个问题,下面是代码:-
MainService.java
public void someMethod(Message message){
A aObj = new A (someEnumClass.enumValue, message)
someService.saveData(aObj)
}
public Class A extends B {
int x,y,z;
A(SomeEnumClass enumValue,int c){
super(enumValue);
}
Public abstract class B<EnumClass extends Enum<EnumClass>>{
private EnumClass enumValue
}
现在上面的代码可以工作了:
但是当我使用下面的类进行测试时
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class MyDemoTests {
@Autowired
private SomeService someService;
@Autowired
private someRepo repository;
@Test
public void testMyservice() throws Exception {
List<A> results = repository.findAll();
assertThat(results).containsAll(all);
}
我在“结果”中收到以下错误:-
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.lang.Enum` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: (InputStreamReader); line: 1, column: 123] (through reference chain: com.example.A["enumValue"])
非常感谢。谢谢
【问题讨论】:
-
什么是
opr?saved1是什么?saved1.getI()返回什么?怎么会有人回答这个问题?
标签: java json spring spring-boot spring-cloud-stream