小编Sai*_*zad的帖子

Spring Boot 单元测试

我是弹簧靴的新手。需要一些建议 这是我的单元测试课

@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

java junit spring-boot

5
推荐指数
1
解决办法
2412
查看次数

factory-boy为工厂创建子工厂列表

我正在使用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数据库的列表

django factory factory-boy

4
推荐指数
2
解决办法
2585
查看次数

Java 将一个类转换为另一个类

假设我有 2 个类,其中一个是 CustomerForm,具有以下属性名称、密码。另一个类 CustomerDomain 具有以下相同的属性名称、密码。我想将 CustomerForm 对象转换为 CustomerDomain。最流行、最便捷的方式是什么?

实际上我正在使用 Spring Boot、FormValidation 并保存到数据库。

java validation spring-boot

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×2

spring-boot ×2

django ×1

factory ×1

factory-boy ×1

junit ×1

validation ×1