#java
Spring
→ spring equivalent
- JSR-330 : standard specification
Good spring resources to begin with:
- Spring Start Here by Laurențiu Spilcă (Manning, 2021)
- Spring in Action , sixth edition, by Craig Walls (Manning, 2022).
- Spring Boot: Up & Running by Mark Heckler (O’Reilly, 2021)
→ spring initializer
→ spring and containers
- integration of Spring Boot with Cloud Native Buildpacks ( https://buildpacks.io ),
→ spring data
Support of nosql databases
→ spring boot
An set of opinioniated spring starter applications such web or other
→ spring batch
For batche jobs
→ spring cloud
- https://docs.spring.io/spring-cloud-stream/docs/4.0.3/reference/html/spring-cloud-stream.html#spring-cloud-stream-reference
- it supports the processor api
→ spring annotations
These annotations are called stereotype
because they are part of a package named org.springframework.stereotype. This package groups together all annotations used to define beans. These annotations are also relevant to the role of a bean.
- @ComponentScan defines the packages that Spring should scan for annotations for bean definitions.
- @ImportResource
- @Component : @Service is a specialization of @Component, which indicates that the annotated class is providing a business service to other layers within the application.
- @Service is used to define a service bean, which is a more complex functional bean that provides services that other beans may require
- @Repository is used to define a bean that is used to retrieve/save data from/to a database, etc.
- @Autowired to tell the Spring IoC container to look for a bean of that type and use it as an argument when calling that method. The stereotype annotations can have as a parameter the name of the resulting bean.
- @Qualifier : done by name. This is done using the @Qualifier annotation, together with the @Autowired annotation, and
- @Ressource
- @Value
- @Scope("prototype") used to define the bean scope, when the desired scope is other than singleton.
- @Lazy annotation is used at the class level to declare beans that will be instantiated the first time they are accessed providing the name of the bean being injected as an argument for it.
- @Configuration. The @Configuration annotation is used to inform Spring that this is a Java-based configuration file.
- @Bean(initMethod = "init") will contain methods annotated with @Bean definitions that represent the bean declarations. The @Bean annotation is used to declare a Spring bean and the DI requirements
- @DependsOn This annotation tells Spring that a certain bean depends on some other beans, so Spring will make sure that those beans are instantiated first.
- @Profile (-Dspring.profiles.active="highschool")
For testing purpose:
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(classes={KindergartenConfig.class, HighschoolConfig.class})
- @ActiveProfiles("kindergarten")
- @SpringBootTest: Integration tests cover the interactions among software components, and in Spring they require an application context to be defined. The spring-boot-starter-test dependency also imports the test utilities from Spring Framework and Spring Boot.
→ dependency injection
- Constructor injection
- method injection
- field injection
→ spel
- Spring Expression Language (SpEL)
→ spring docker
- better to layer the jar content to save space, network and also image build time
java -Djarmode=layertools -jar catalog-service.jar extract
- Cloud Native Buildpacks with Emily Casey
→ Testing in spring boot
This page was last modified: