Spring Core Cheat Sheet: Container, Dependency and IOC
Spring Core Cheat Sheet: Container, Dependency and IOC
Spring Core Cheat Sheet: Container, Dependency and IOC
<dependency>
<groupId>org.springframework</groupId> @Component
<artifactId>spring-context</artifactId> public class DummyServiceImpl implements
</dependency> DummyService {
}
@ComponentScan("fr.sii.cheatsheet.spring") @Component
public class MyApp { public class FooServiceImpl implements FooService
{
public static void main(String[] args) {
ApplicationContext app = new @Autowired
AnnotationConfigApplicationContext(MyApp.class); private DummyService service;
@Autowired
Prefer use of a con guration class
public DummyService
setDummyService(DummyService dummyService) {
@Configuration this.service = dummyService;
public class MyAppConfig { }
// @Bean, ...
} }
@PreDestroy https://spring.io/guides
https://spring.io/projects/spring-framework
Spring Core documentation
SPEL : SPRING EXPRESSION LANGUAGE Spring Boot cheat sheet
@Value("#{myBean.myValue}")
private String myValue;
Parse a string
@Value("#{myBean.myValue.substring(0,1)}")
private String myValue;
Operations