我是弹簧靴的新手。需要一些建议 这是我的单元测试课
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = DemoApplication.class)
public class EmployeeRepositoryTest {
@Autowired
protected EmployeeRepository employeeRepository;
@Test
public void insertEmploee(){
Employee employee = new Employee();
employee.setEmpName("Azad");
employee.setEmpDesignation("Engg");
employee.setEmpSalary(12.5f);
employeeRepository.save(employee);
}
Run Code Online (Sandbox Code Playgroud)
}
当我运行它时,我得到异常
java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotationAttributes(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/String;ZZ)Lorg/springframework/core/annotation/AnnotationAttributes;
at org.springframework.test.util.MetaAnnotationUtils$AnnotationDescriptor.<init>(MetaAnnotationUtils.java:290)
at org.springframework.test.util.MetaAnnotationUtils$UntypedAnnotationDescriptor.<init>(MetaAnnotationUtils.java:365)
at org.springframework.test.util.MetaAnnotationUtils$UntypedAnnotationDescriptor.<init>(MetaAnnotationUtils.java:360)
at org.springframework.test.util.MetaAnnotationUtils.findAnnotationDescriptorForTypes(MetaAnnotationUtils.java:191)
at org.springframework.test.util.MetaAnnotationUtils.findAnnotationDescriptorForTypes(MetaAnnotationUtils.java:198)
at
Run Code Online (Sandbox Code Playgroud)
进程完成,退出代码 -1
我正在使用django 1.6和factory-boy。
class UserFactory(factory.Factory):
class Meta:
model = models.User
username = factory.Sequence(lambda n: 'user%d' % n)
Run Code Online (Sandbox Code Playgroud)
这username是一个简单CharField的模型。这样,每次调用时,UserFactory()我都会保存并获取唯一的用户命名对象。
在工厂男孩中,我可以使用factory.SubFactory(SomeFactory)。
我如何生成SomeFactoryin的列表ParentOfSomeFactory?
这样,如果我打电话,ParentOfSomeFactory()我将创建SomeFactory以及ParentOfSomeFactory数据库的列表
假设我有 2 个类,其中一个是 CustomerForm,具有以下属性名称、密码。另一个类 CustomerDomain 具有以下相同的属性名称、密码。我想将 CustomerForm 对象转换为 CustomerDomain。最流行、最便捷的方式是什么?
实际上我正在使用 Spring Boot、FormValidation 并保存到数据库。