簡體   English   中英

java.lang.IllegalAccessException:. 無法使用修飾符“private static”訪問類 CrossOrigin 的成員

[英]java.lang.IllegalAccessException:.cannot access the member of class CrossOrigin with modifiers "private static"

我正在嘗試使用一些用@CrossOrigin 注釋的端點來模擬控制器類。 它給出了這個例外。

引起: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
@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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM