简体   繁体   English

java.lang.IllegalAccessException:. 无法使用修饰符“private static”访问类 CrossOrigin 的成员

[英]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
}
}
  • this will help to you这对你有帮助
  • You can use annotation @CrossOrigin您可以使用注释@CrossOrigin
@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.

相关问题 java.lang.IllegalAccessException:类 zyxuSimpleCompileTest 无法访问带有修饰符“”的类 MyClass 的成员 - java.lang.IllegalAccessException: Class z.y.x.u.SimpleCompileTest can not access a member of class MyClass with modifiers “” 在 Java 中访问对象的字段值 - 无法访问 class java.lang.IllegalAccessException 的成员 - Access an Object's field values in Java - cannot access a member of class java.lang.IllegalAccessException jsonobject IllegalAccessException无法使用修饰符“private”访问类java.util.HashMap的成员 - jsonobject IllegalAccessException can not access a member of class java.util.HashMap with modifiers “private” java.lang.IllegalAccessException:与类的public / private属性有关吗? - java.lang.IllegalAccessException: is related to public / private attribute for classes? Java反射,java.lang.IllegalAccessException错误 - Java Reflection, java.lang.IllegalAccessException Error 使用处理java、java.lang.IllegalAccessException - Using processing java , java.lang.IllegalAccessException 无法实例化服务service.FetchAddressIntentService:java.lang.IllegalAccessException:不允许访问构造函数 - Unable to instantiate service service.FetchAddressIntentService: java.lang.IllegalAccessException: access to constructor not allowed java.lang.IllegalAccessException:试图从非可视上下文访问可视服务 WindowManager - java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context java.lang.IllegalAccessException:class io.netty.util.internal.PlatformDependent0$6 - java.lang.IllegalAccessException: class io.netty.util.internal.PlatformDependent0$6 春季:FasterXML无法使用修饰符private访问类的成员 - Spring : FasterXML cannot access a member of class with modifiers private
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM