0

I have a controller superclass and its subclass:

public class SuperController { @Resource private A resourceA; } public class SubController extends SuperController { @Resource private B resourceB; } 

I don't use resourceA field in Subcontroller, but Subcontroller acts as SuperController and has the same methods. So how can I forbit the inheritance of @Resource annotation, just like that:

public class SuperController { **private** @Resource private A resourceA; } 

1 Answer 1

1

Sounds like you need a common abstract class if the sub-class doesn't use some of the fields of the parent class.

public abstract class AbstractController { // common fields. // common methods. } public class SuperController extends AbstractController { @Resource private A resourceA; } public class SubController extends AbstractController { @Resource private B resourceB; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.