Когда использовать DebuggerDisplayAttribute

Каковы некоторые передовые методы работы с DebuggerDisplayAttribute ? Что определяет ваше решение о том, когда и как применять атрибут к вашему коду? Например ..

  1. Считаете ли вы DebuggerDisplayAttribute более полезным для некоторых типов объектов (например, пользовательских структур данных), чем для других?
  2. Определяете ли вы его для общедоступных типов, внутренних типов или обоих ?
  3. Вы обычно добавляете его в первоначальную реализацию, открытый класс DefaultService расширяет MyService { } and a class using this bean public class Consumer { @Autowired @Qualifier("...

    Given I have a Spring bean configured as

    @Service("myService")
    public class DefaultService extends MyService {
    }
    

    and a class using this bean

    public class Consumer {
        @Autowired
        @Qualifier("myService")
        private MyService service;
        ...
    }
    

    I now want my project, that includes the preceding classes, to have Consumer another implementation of MyService being injected. Therefore I would like to overwrite the bean myService

    @Service("myService")
    public class SpecializedService implements MyService {
    }
    

    resulting in Consumer carrying now an instance of SpecializedService instead of DefaultService. By definition I cannot have two beans with the same name in the Spring container. How can I tell spring, that the definition of the new service shall overwrite the older one? I don't want to modify the Consumer class.

7
задан Lars Blumberg 7 April 2011 в 04:49
поделиться