Important Annotations
@SpringBootTest & @Test
@SpringBootTest & @Test
@Component
@Component
It is an annotation that allows Spring to automatically detect our custom beans
Can only be annotate on a class
@Service
and@Repository
are special cases of@Component
.
@Service
@Service
Service Components are the class file which contains @Service annotation. These class files are used to write business logic in a different layer, between @RestController
class and @Repository
@Repository
@Repository
@Repository annotates classes at the persistence layer, which will act as a database repository.
@Autowired
@Autowired
Enables automatic dependency injection. In other words, by declaring all the bean dependencies in a Spring configuration file, Spring container can auto wire relationships between collaborating beans. This is called Spring bean auto-wiring.
@Primary
@Primary
There's another annotation called @Primary that we can use to decide which bean to inject when ambiguity is present regarding dependency injection.
This annotation defines a preference when multiple beans of the same type are present.
@EnableConfigurationProperties
@EnableConfigurationProperties
To load config from Class, refer below annotation
@ConfigurationProperties("secret")
Last updated