InsideDarkWeb.com

@RequestMapping can not use a static final constant in parent class which is not in same package with subclass

when @RequestMapping used a static final constan in parent class which is not in same package with subClass class,the idea give me a error like

‘V1_BASE_URL’ has protected access in ‘XXXXXXXX.BaseController’

so,i dont know why,the next is my code.

this is the parent class

package com.controller;
public class BaseController {

protected static final String V1_BASE_URL = "/crm/v1/";

}

this is subclass,and it is not in the same package with BaseController

package com.controller.corpus;
@RequestMapping(V1_BASE_URL+"/crm/v1/corpus_subset")
public class CorpusSubsetController extends BaseController {

}

error image

i dont find some useful answer can deal my problem,but i found if the subclass and father in the same package,the annotation in classname can use static constant,but if the subclass not in the same package with father, the annotation can not use,so my question is the annotation in classname belongs who?if the annotation in a class which one in the package A,so the annotation belongs the package A??

Stack Overflow Asked on November 15, 2021

1 Answers

One Answer

It's because you are trying to access V1_BASE_URL in the annotation which is outside the class scope. If you access it like this you won't have any compilation errors for example :

public class CorpusSubsetController extends BaseController {
    public void test() {
        String test = V1_BASE_URL;
    }
}

Answered by Fabien on November 15, 2021

Add your own answers!

Related Questions

Delphi Parse JSON

2  Asked on February 17, 2021 by stanley-mladenek

   

How to create a filter using bootstrap and jQuery

2  Asked on February 17, 2021 by jefin-winston

     

Change Canvas sizes with zoom

0  Asked on February 17, 2021 by reit-abdullah-yavuzkol

 

Is there a way to make the Loop Code make it faster?

4  Asked on February 17, 2021 by levesque-xylia

 

Using libcurl in g++

0  Asked on February 16, 2021 by marcel-kopera

   

how to count number of file with a matching pattern using python

2  Asked on February 16, 2021 by suryansh-mathur

 

R First Row By Group When Condition Is Met

4  Asked on February 16, 2021 by bvowe

   

C++ program won’t print anything with vectors?

2  Asked on February 16, 2021 by luckylone-official

 

What is damping for?

3  Asked on February 16, 2021 by lix

       

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.