[英]java.lang.IllegalAccessException:.cannot access the member of class CrossOrigin with modifiers "private static"
I am trying to mock the controller class with some endpoints annotated with @CrossOrigin.我正在尝试使用一些用@CrossOrigin 注释的端点来模拟控制器类。 it is giving this exception.它给出了这个例外。
Caused by: java.lang.IllegalAccessException: Class net.bytebuddy.description.annotation.AnnotationDescription$ForLoadedAnnotation can not access a member of class org.springframework.web.bind.annotation.CrossOrigin with modifiers "private static"引起:java.lang.IllegalAccessException:类 net.bytebuddy.description.annotation.AnnotationDescription$ForLoadedAnnotation 无法访问带有修饰符“private static”的类 org.springframework.web.bind.annotation.CrossOrigin 的成员
@Runwith(PowerMockRunner.class)
class TestDemo
{
@Mock
private ControllerTest con;
}
class ControllerTest
{
@CrossOrigin
@RequestMapping
public void testCon()
{
//code implementation
}
}
@CrossOrigin(origins = {"http://localhost:85960"}, maxAge = 5000, allowCredentials = "false")
@CrossOrigin(origins = {"http://localhost:5960"}, maxAge = 5000, allowCredentials = "false")
@RestController
@RequestMapping("/api")
public class testRestController{
@CrossOrigin(origins = {"http://localhost:5959"}, maxAge = 800)
@RequestMapping("/test")
public List<Student> showData() {
List<Student> studentlist = List<Student>();
return studentlist
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.