Posts

@Primary In Spring Framework

 @Primary In Spring Framework @Primary @Bean (name = "jdbcMainNamedParameterJdbcTemplate" ) public NamedParameterJdbcTemplate namedParameterJdbcTemplate () { return new NamedParameterJdbcTemplate(dataSource()) ; } @Bean (name = "jdbcMainNamedParameterJdbcTemplateForReplica" ) public NamedParameterJdbcTemplate namedParameterJdbcTemplateForReplica () { return new NamedParameterJdbcTemplate(dataSourceForReplica()) ; In Spring Framework, @Primary is an annotation used to indicate a primary bean when multiple beans of the same type are present. When you have more than one bean of the same type, Spring needs to know which one to inject where. The @Primary annotation tells Spring that a particular bean should be given preference when there are multiple candidates. In your code snippet, you have two beans of type NamedParameterJdbcTemplate : jdbcMainNamedParameterJdbcTemplate jdbcMainNamedParameterJdbcTemplateForReplica Both beans are of the same type, so if you in...

Protocol Buffers with Java & Gradle

Image
 

Design Patterns

Image
 

SOLID principles in Java

  What are the SOLID principles in Java?   What are the SOLID principles in Java?  SOLID  principles are object-oriented design concepts relevant to software development. SOLID is an acronym for five other class-design principles:  S ingle Responsibility Principle,  O pen-Closed Principle,  L iskov Substitution Principle,  I nterface Segregation Principle, and  D ependency Inversion Principle. Principle Description Single Responsibility Principle Each class should be responsible for a single part or functionality of the system. Open-Closed Principle Software components should be open for extension, but not for modification. Liskov Substitution Principle Objects of a superclass should be replaceable with objects of its subclasses without breaking the system. Interface Segregation Principle No client should be forced to depend on methods that it does not use. Dependency Inversion Principle High-level modules should not depend on low-level modul...